Need help with Plotting inside a time loop please!

t = [0:100]; wavomega=0.5; f=100; if t>10 && t<15 Ft = f*sin(wavomega*t); else Ft =0; end figure; plot(Ft,t)
This gives an error and says t is not a scalar?? Please help how to plot this.? Is it because Ft is changing in every loop?
Please help.

Respuestas (2)

John BG
John BG el 22 de Abr. de 2016
Instead of the if, use directly
Ft=zeros(1,length(t))
Ft = f*sin(wavomega*t(11:14))
If you find this answer of any help solving your question, please click on the thumbs-up vote link, or mark it as accepted answer
thanks in advance
John
Vignesh Kumar
Vignesh Kumar el 22 de Abr. de 2016

0 votos

Thank John,
ITs not working. Says * matrix dimensions must match

1 comentario

Vignesh
this works:
t = [0:100];
wavomega=0.5;
f=100;
Ft=zeros(1,length(t))
Ft([11:14]) = f*sin(wavomega*t([11:14]));
stem(t,Ft)
is this ok? regards
John

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 21 de Abr. de 2016

Comentada:

el 22 de Abr. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by