Hi Takura
I believe you want to loop through the code until the guessed value is equal to the calculated value.
In order to acheive that you can use a while loop to iterate over your code. For example,
close;
clear;
Wguess=input('input weight guess');
WTO=input('input original weight');
WE=input('input empty weight');
WF=input('input fuel weight');
WPAY=input('input payload weight');
AW0=WE/WTO;
WFRAC=WF/WTO;
% Start a while loop to repeat the process until the guessed value is correct
while Wcalc ~= Wguess
Wcalc=(WPAY)/(1-WFRAC-AW0);
% Check if the calculated value matches the guessed value
if Wcalc==Wguess
WTO=Wcalc;
break;
end
% Update the guessed value for the next iteration
Wguess=Wcalc;
Wcalc=(WPAY)/(1-(WF/WTO)-(WE/WTO));
end
% Display the final takeoff weight
disp(['The takeoff weight is: ' num2str(WTO)])
I hope this resolves your query.
Regards,
Tushar