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.

回答(1 个)

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

1 个评论

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

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by