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 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Torsten
el 9 de Mzo. de 2022
Editada: Torsten
el 9 de Mzo. de 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.
Respuestas (1)
David Hill
el 9 de Mzo. de 2022
Editada: David Hill
el 9 de Mzo. de 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 comentarios
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!