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.

Antworten (1)

madhan ravi
madhan ravi am 11 Dez. 2018

0 Stimmen

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

1 Kommentar

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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 11 Dez. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by