Why can I not evaluate this while loop?

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

I totally forgot that how MATLAB handles radians and degrees. Thank you for the reminder.

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

on 11 Sep 2015

Commented:

on 11 Sep 2015

Community Treasure Hunt

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

Start Hunting!