I need to find out what this program is missing

1 view (last 30 days)
I'm trying to use this program to calculate the cos of a given(prompted) angle in degrees.
A=input('Enter angle:');
format long
c=c+sg*((x^(2*a))/(factorial(2*a))); % Infinite series calculation.
fprintf('cos = %6f',c);
I get no answer and I have to close Matlab and restart.

Sign in to comment.

Accepted Answer

Albert Yam
Albert Yam on 12 Jul 2012
while [condition] %that should only be true to run the loop
%stuff in loop
end % make sure to end the loop, but should give a warning about that
If your condition is just a constant, than your loop is always running. But your code is not 'copy/paste'-able into Matlab for us to check.
Aaron on 12 Jul 2012
I will remember to use the {} next time. Thank you for your help.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!