필터 지우기
필터 지우기

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 (최근 30일)
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

답변 (1개)

jonas
jonas 2018년 9월 30일
편집: jonas 2018년 9월 30일

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.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by