Borrar filtros
Borrar filtros

How do I make an efficient While loop? setting true = 0, then while true = 0, results in an error on the while line. of code. What is wrong with that logic?

1 visualización (últimos 30 días)
I want to run this while loop, and want to make sure i am doing it an efficient manner. I'm a beginner level matlab user in college. I want the loop to run until I meet the condition that WoCalculated be within 99.99% of WoGuess.
Wfinal_Wo = FinalLand.*ReturnCruise_Wi.*TotalClimbingWeightFraction.*TotalLandingWeightFraction.*w3_w2.*w2_w1.*w1_wo;
Wfuel_Wo = 1.06.*(1-Wfinal_Wo);
WoGuess = 95000;
WoCalculated = 1;
% Wempty_Wo = 1.09*Wo.^-.05
true = 0;
while true = 0
We_Wo = 1.09.*WoGuess.^-.05;
%Weight of water and crew is 25,500 and 750 respectively
WoCalculated = (26250)./(1 - Wfuel_Wo - We_Wo);
if (WoCalculated/WoGuess) >= .9999
true = 1;
else
WoGuess = WoCalculated;
end
end

Respuestas (1)

jonas
jonas el 30 de Sept. de 2018
Editada: jonas el 30 de Sept. de 2018

Use == for logical operations. Also do not call your variable true. Writing

while true=0

is very counterintuitive, as true has a specific meaning in matlab.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by