Use newline, comma or semicolon before this statement

5 views (last 30 days)
I have written a function but keep getting a 'red' error message telling me to 'use a newline, comma or semicolon before this statement'...'this statement' being the addition sign in the first equation. I have tried various alterations but cant seem to get it to work or if I have written it all wrong??
function E = m + (180/pi20)* e * sind(m)* (1 + e *cos(m));
keeplooping = true;
while E > 0.005
E1 = (E - (180/pi20)* ec *sind(E)-m)/(1-ec *cosd(E));
E1 = E;
keeplooping;
if E <= 0.005
keeplooping = false
return
end
end
end

Accepted Answer

Star Strider
Star Strider on 2 Jun 2017
I can’t tell if it’s all wrong, but this statement certainly is:
function E = m + (180/pi20)* e * sind(m)* (1 + e *cos(m));
If you want to create a function file, see the documentation on Function Basics (link). If you want to create an anonymous function, see the documentation on Anonymous Functions (link).
I can’t figure out what you’re doing, so I’ll not venture a solution. One possible ‘fix’ would be to delete the function word from this line and just use it as:
E = m + (180/pi20)* e * sind(m)* (1 + e *cos(m));

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!