table from the variable from the loop
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone, could you please help me how to calculate the table from the generated variables from the loop
For example, from the second loop, the table with a colums of V, D, F, W, t
my code is :
clear all; close all
W_takeoff = 10000;
W_landing=6000;
S = 20;
AR = 5;
cd0 = 0.02;
k = 1/pi/AR;
RC=0.51;
clalpha = 2*pi;
amin=2;
astall=12;
rho=1;
ct=0.001;
figure(1);hold on; xlabel('V');ylabel('D')
figure(2);hold on; xlabel('V');ylabel('D')
figure(3);hold on; xlabel('V');ylabel('P')
figure(4);hold on; xlabel('V');ylabel('P')
figure(5);hold on; xlabel('\alpha');ylabel('c_l/c_d^2')
i=0;
for alpha = amin:0.25:astall
i=i+1;
cl(i) = clalpha * alpha * pi/180;
V_takeoff(i) = sqrt(2*W_takeoff/rho/S/cl(i));
V_landing(i) = sqrt(2*W_landing/rho/S/cl(i));
cd(i) = cd0 + k * cl(i) * cl(i);
D_takeoff(i) = 0.5 * rho * V_takeoff(i) * V_takeoff(i) * S * cd(i);
D_landing(i) = 0.5 * rho * V_landing(i) * V_landing(i) * S * cd(i);
p_takeoff(i) = D_takeoff(i)*V_takeoff(i);
p_landing(i) = D_landing(i)*V_landing(i);
P_takeoff(i)=20000+500*V_takeoff(i);
T_takeoff(i)=20000/V_takeoff(i)+500;
P_landing(i)=20000+500*V_landing(i);
T_landing(i)=20000/V_landing(i)+500;
cl_cd2(i)=cl(i)/(cd(i)*cd(i));
ang(i)=alpha;
end
figure(1); plot(V_takeoff,D_takeoff)
hold on
plot(V_takeoff,T_takeoff)
title(['Takeoff'])
figure(2); plot(V_landing,D_landing)
hold on
plot(V_landing,T_landing)
title(['Landing'])
figure(3); plot(V_takeoff,p_takeoff)
hold on
plot(V_takeoff,P_takeoff)
title(['Takeoff'])
figure(4); plot(V_landing,p_landing)
hold on
plot(V_landing,P_landing)
title(['Landing'])
figure(5); plot(ang,cl_cd2);
alpha_max=3;
cl_max=clalpha*alpha_max*pi/180;
cd_max = cd0 + k * cl_max * cl_max;
j=0;
for w=W_takeoff:-50:W_landing
j=j+1;
V(j) = sqrt(2*w/rho/S/cl_max);
D(j) = 0.5 * rho * V(j) * V(j) * S * cd_max;
T(j)=D(j); %for steady level flight condition
F(j)=ct*T(j); %fuel consumption
Weight(j)=w;
t(j)=abs((Weight(j)-10000))/F(j);
R(j)=V(j)*t(j);
end
[max_delta,idelta] = max(abs(D_takeoff-T_takeoff));
figure(6); plot(t,V)
figure(7); plot(t,F);
figure(8); plot(t,R);
댓글 수: 0
채택된 답변
Matt J
2023년 3월 30일
편집: Matt J
2023년 3월 30일
j=0;
for w=W_takeoff:-50:W_landing
j=j+1;
V(j,1) = sqrt(2*w/rho/S/cl_max);
D(j,1) = 0.5 * rho * V(j) * V(j) * S * cd_max;
T(j,1)=D(j); %for steady level flight condition
F(j,1)=ct*T(j); %fuel consumption
Weight(j,1)=w;
t(j,1)=abs((Weight(j)-10000))/F(j);
R(j,1)=V(j)*t(j);
end
W=Weight;
T=table(V, D, F, W, t)
T =
81×5 table
V D F W t
______ ______ _______ _____ ______
55.133 817.37 0.81737 10000 0
54.995 813.28 0.81328 9950 61.479
54.857 809.19 0.80919 9900 123.58
54.718 805.11 0.80511 9850 186.31
54.579 801.02 0.80102 9800 249.68
: : : : :
43.412 506.77 0.50677 6200 7498.5
43.236 502.68 0.50268 6150 7658.9
43.06 498.59 0.49859 6100 7822
42.883 494.51 0.49451 6050 7987.8
42.706 490.42 0.49042 6000 8156.3
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!