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 件)

madhan ravi
madhan ravi 2018 年 12 月 11 日

0 投票

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

1 件のコメント

Dominykas Repecka
Dominykas Repecka 2018 年 12 月 11 日
Could you give an example how and where would it play the role in my loop?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2018 年 12 月 11 日

コメント済み:

2018 年 12 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by