just signed up and can't figure it out as it says :"Error using plot Vectors must be the same length."
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Abdallah Almughrabi
am 21 Okt. 2021
Kommentiert: Abdallah Almughrabi
am 21 Okt. 2021
clear
clc
x = 0:pi/16:2*pi;
f = (sin(x).^2).*cos(2*x);
k = diff(f);
plot(x,k);
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 21 Okt. 2021
The result of diff is a vector (you named it k) that has one element less than the input vector (you named it f). The error message, then, is that you inputs to the plot function are not the same length.
Try this.
x = 0:pi/16:2*pi;
f = (sin(x).^2).*cos(2*x);
k = [0 diff(f)];
plot(x,k);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!