Is this how I find the area under my graph?
Afficher commentaires plus anciens
I have this code which takes too long to run so I would save you the trouble and just attach a snippet of how I plotted the graph and called the trapz for finding the area. However, I did this but my answer seems quite far off from my caluclations so I am wondering if this was the right method to find the area under the graph. I'd like to know if I did something wrong or this answer is correct. 

So this is the graph I generated and I'll attach the code below.
%% Maximum ROC vs V by taking the maximum ROC at each altitude
% ------ Functions to solve for FSOLVE (steady climbing flight) ------ %
% func1 = v' = 1/m *(T-D-mgsin(gamma)) = 0
% func2 = gamma' = 1/mu * (L-mgcos(gamma)) = 0
% func3 = Cm = 0
% ------ FSOLVE variables ------ %
% x(1) = velocity
% x(2) = deltae
% x(3) = gamma
% ------ Altitude range from flight envelope ------ %
hlist_2_5 = linspace(0,9000,300);
hlist_3 = linspace(0,17000,300);
% ------ Array for storing ------ %
% 1: V 2:deltae 3:gamma 4:aoa 5:roc 6. altitude 7. thrust 8. 1/ROC
final_list_2_5 = zeros(length(hlist_2_5),8);
final_list_3 = zeros(length(hlist_3),8);
%% PS = 2.5
%% --REMOVED-- the calculations
for j = 1:length(hlist_2_5)
[max_roc, index] = max(store_v_de_gam_aoa_roc(:,5));
final_list_2_5(j,5) = max_roc; % ROC
final_list_2_5(j,1) = store_v_de_gam_aoa_roc(index,1); % V
final_list_2_5(j,2) = store_v_de_gam_aoa_roc(index,2); % deltae
final_list_2_5(j,3) = store_v_de_gam_aoa_roc(index,3); % gamma
final_list_2_5(j,4) = store_v_de_gam_aoa_roc(index,4) % aoa
final_list_2_5(j,6) = hlist_2_5(j) % h
final_list_2_5(j,7) = store_v_de_gam_aoa_roc(index,6) % thrust
final_list_2_5(j,8) = 1/max_roc; % 1/ROC
end
%% PS = 3
%% --REMOVED-- the calculations
for j = 1:length(hlist_3)
[max_roc, index] = max(store_v_de_gam_aoa_roc(:,5));
final_list_3(j,5) = max_roc; % ROC
final_list_3(j,1) = store_v_de_gam_aoa_roc(index,1); % V
final_list_3(j,2) = store_v_de_gam_aoa_roc(index,2); % deltae
final_list_3(j,3) = store_v_de_gam_aoa_roc(index,3); % gamma
final_list_3(j,4) = store_v_de_gam_aoa_roc(index,4) % aoa
final_list_3(j,6) = hlist_3(j) % h
final_list_3(j,7) = store_v_de_gam_aoa_roc(index,6) % thrust
final_list_3(j,8) = 1/max_roc; % 1/ROC
end
% ------ Finding time to climb to each altitude ------ %
time_2_5_climb = trapz(final_list_2_5(:,8),final_list_2_5(:,6))
% 92475.4221575 s = 25.7 hours <-- this is the result I got
time_3_climb = trapz(final_list_3(:,8),final_list_3(:,6))
% 164693.805554 s = 45.7 hours <-- this is the result I got
% ------ Plotting graph (X vs Y)------ %
figure % 1/ROC vs Altitude
plot(final_list_2_5(:,6),final_list_2_5(:,8))
hold on
plot(final_list_3(:,6),final_list_3(:,8))
xlabel('Altitude [m]')
ylabel('1/Rate of climb [s/m]')
title('1/Rate of climb vs Altitude')
legend('PS = 2.5','PS = 3')
grid on
1 commentaire
Rachel Ong
le 10 Mar 2022
Modifié(e) : Rachel Ong
le 10 Mar 2022
Réponse acceptée
Plus de réponses (0)
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!