Code will not plot graph when I try to change my payload vector increment.
Afficher commentaires plus anciens
My code is supposed to display a plot of the Range vs Payload of an aircraft, however, when I try and change the increment of my payload vector from 100, the plot comes up blank. It will not even include my title or axes labels. Let me know what I need to fix to allow me to change my increment and still have the plot display. It shows there is a potential error with the length of the payload and the range vectors when it gets to the point of plotting if I change the incerment.
% PAYLOAD CALULATIONS
TotalPassengerWeight = Passengers * PassengerWeight;
TotalLuggageWeight = Luggage * LuggageWeight;
MaxPayload = TotalPassengerWeight + TotalLuggageWeight;
Payload = [0:100:MaxPayload];
% FUEL CALCULATIONS
i = 1;
while Payload <= MaxPayload & i <= length(MaxPayload)
Fuel(i) = MaxTakeOff - EmptyWeight - Payload(i) - TotalCrewWeight; %kg
i = i + 1;
end
TakeOffFuel = .995 .* Fuel;
ClimbFuel = .980 .* Fuel;
DescentFuel = .990 .* Fuel;
LoiterFuel = .987 .* Fuel;
LandFuel = .992 .* Fuel;
TakeOffFuelUsed = Fuel - TakeOffFuel;
ClimbFuelUsed = Fuel - ClimbFuel;
DescentFuelUsed = Fuel - DescentFuel;
LoiterFuelUsed = Fuel - LoiterFuel;
LandFuelUsed = Fuel - LandFuel;
FuelUsed = TakeOffFuelUsed + ClimbFuelUsed + DescentFuelUsed + LoiterFuelUsed + LandFuelUsed;
% WEIGHT CALCULATIONS
InitialWeight = MaxTakeOff;
FinalWeight = MaxTakeOff - (Fuel - FuelUsed);
% RANGE CALCULATION
Range = (PropellerEfficiency / Ct) * (LtoD) * log(InitialWeight ./ FinalWeight); %m
% PLOT.
figure(1)
hold on
plot(Payload,Range,"r-");
title("Range(m) vs Payload(kg) of a Propeller Aircraft");
xlabel("Payload(m)");
ylabel("Range(m)");
grid on
hold off
Réponse acceptée
Plus de réponses (1)
Yogi
le 28 Nov 2023
0 votes
Halo Hanna, Can i ask for the full code of Payload-Range diagram? Thank you for your sincerity
3 commentaires
Image Analyst
le 28 Nov 2023
@Yogi Why do you think the code here is not the full code:
Yogi
le 28 Nov 2023
I've tried it, but some parameters haven't been defined
Yogi
le 28 Nov 2023
Ohh sorry I didn't read the comment section I just copied on code on the post
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
