Syntax a while loop

7 次查看(过去 30 天)
Philosophaie
Philosophaie 2015-8-28
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

回答(1 个)

Walter Roberson
Walter Roberson 2015-8-28
That syntax is fine. You do not need the () around the condition but it does not hurt.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by