Why can I not evaluate this while loop?

1 view (last 30 days)
t=0;
for w=35:5:45;
while (x<10) & (y<10);
x = exp(1.2)*cos(w*t);
y = t^3;
t=t+0.1;
end
t
end

Accepted Answer

James Tursa
James Tursa on 11 Sep 2015
Edited: James Tursa on 11 Sep 2015
Did you mean to use cosd instead of cos? From your w values it looks like maybe w is in degrees. Also, I don't see x or y initialized. E.g., maybe start with x = exp(1.2) and y = 0 prior to the loop start?
  1 Comment
Tuntoon
Tuntoon on 11 Sep 2015
I totally forgot that how MATLAB handles radians and degrees. Thank you for the reminder.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!