Effacer les filtres
Effacer les filtres

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 vue (au cours des 30 derniers jours)
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

Réponses (1)

jonas
jonas le 30 Sep 2018
Modifié(e) : jonas le 30 Sep 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.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by