I'm trying to plot to function but keep getting an error saying "Vectors must be the same length." how do I fix this
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
for w = [2,5,8]'
for t = (0:1:6)'
T = 0.15;
y = 1./(sqrt(1+(w*T).^2));
y1 = -atan(w*T);
plot(t,y,t,y1)
legend('input','output')
end
end
1 Kommentar
Torsten
am 9 Mär. 2022
Bearbeitet: Torsten
am 9 Mär. 2022
t has length 7, y and y1 both have length 3.
How do you intend to plot a vector with 3 elements against a vector with 7 elements ?
Before you answer again: How to fix this ?, first tell us what you want to plot against what.
Plotting y and y1 against t with
y = 1./(sqrt(1+(w*t).^2));
y1 = -atan(w*t);
only works if you use only one element of the w-vector, not three at a time.
Antworten (1)
David Hill
am 9 Mär. 2022
Bearbeitet: David Hill
am 9 Mär. 2022
Not sure what you are trying to do. There is no t in your questions, only a single variable w. Why the for-loops?
[w,t]=meshgrid([2 5 8],0:6);
y = 1./(sqrt(1+(w.*t).^2));
y1 = -atan(w.*t);
surf(t,w,y);
figure;
surf(t,w,y1);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations 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!