Complicated matlab for loop using user's input

Hello everybody,
So i ran into this problem, where i've got a number x=m:.1:m+4*pi and i have to create a for loop which would increase the m value by pi/8 every 0.5 seconds for 15 times and then graph it and I just have no idea how to make it work.. so far I have done this much:
%------
prompt='Iveskite skaiciu m: ';
m=input(prompt);
x=m:.1:m+4*pi;
prompt2='Pasirinkite funkcija cos(B)/sin(A): ';
f=input(prompt2,'s');
if strcmp(f,'A')
fun=@sin;
elseif strcmp(f,'B')
fun=@cos;
else
error('invalid selection')
end
figure(1),clf(1)
plot(x,fun(x))
%------
for a = 0:15
for k = m:0.1:m<m+4*pi
x(a,k) = m:.1:m+4*pi;
end
end
It's not much, but I tried my best.
By the way, the number m is a user's input.

Respuestas (1)

madhan ravi
madhan ravi el 11 de Dic. de 2018

0 votos

str2func() should play a role here just look into the doc

1 comentario

Could you give an example how and where would it play the role in my loop?

Iniciar sesión para comentar.

Categorías

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

Preguntada:

el 11 de Dic. de 2018

Comentada:

el 11 de Dic. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by