loop to calculate time using previous values
1 回表示 (過去 30 日間)
古いコメントを表示
Hello everyone!
Could you please help me with a code.
I have a loop and calculated time, so the values of time are the increments between the current and previous values. So how to generate the loop for the time where the previous ones can be added. For example, my first t values are 60.6664, 60.9712, 61.2792, 61.5902, 61.9045........ In the result of new time will be 60.9712, (60.9712+61.2792), (60.9712+61.2792+61.5902)......
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;
alpha_max=2.95;
cl_max=clalpha*alpha_max*pi/180;
cd_max = cd0 + k * cl_max * cl_max;
delta_w=50;
j=0;
for w=W_takeoff:-delta_w: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;
Thrust(j)=D(j); %for steady level flight condition
F(j)=ct*Thrust(j); %fuel consumption
Weight(j)=w;
t(j)=delta_w/F(j);
R(j)=V(j)*t(j);
end
0 件のコメント
回答 (1 件)
Dyuman Joshi
2023 年 3 月 31 日
編集済み: Dyuman Joshi
2023 年 3 月 31 日
You can vectorize the loop -
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;
alpha_max=2.95;
cl_max=clalpha*alpha_max*pi/180;
cd_max = cd0 + k * cl_max * cl_max;
delta_w=50;
j=0;
w=W_takeoff:-delta_w:W_landing;
V = (2*w/rho/S/cl_max).^(1/2);
D = 0.5*rho*V.^2*S*cd_max;
Thrust = D;
F = ct*Thrust;
Weight = w;
t = delta_w./F
R = V.*t;
%new time
T = cumsum(t)
2 件のコメント
Dyuman Joshi
2023 年 3 月 31 日
編集済み: Dyuman Joshi
2023 年 4 月 4 日
Apologies, @Alina Abdikadyr, there was a mistake in the formula of V which has been rectified. Please check my answer again.
参考
カテゴリ
Help Center および File Exchange で Introduction to Installation and Licensing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!