Syntax a while loop

I am not sure I have the syntax right on my while loop: And I am taking the absolute value with the abs command.
EA1 = pi / 4;
diff = 1;
while (abs(diff) > 0.000001)
diff = (EA1 - e * sin(EA1) - MA) / (1 + e * cos(EA1));
EA1 = EA1 + diff;
end

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de Ag. de 2015

0 votos

That syntax is fine. You do not need the () around the condition but it does not hurt.

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Ag. de 2015

Respondida:

el 28 de Ag. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by