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 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Torsten
il 9 Mar 2022
Modificato: Torsten
il 9 Mar 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.
Risposte (1)
David Hill
il 9 Mar 2022
Modificato: David Hill
il 9 Mar 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 Commenti
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!