Trying to find a value at a specific point in an array.

7 ビュー (過去 30 日間)
Chett Manly
Chett Manly 2021 年 10 月 24 日
コメント済み: Chett Manly 2021 年 10 月 24 日
What I am trying to do is find the value of Hmax @ Tmax.
Tmax is a product of Vmax.
clear; close all; clc
G = 9.80665; %gravity
D = 0.1;
v0 = 0; %Start velocity
h0 = 38969; %start height
t0 = 0; %start time
T = 0.01;
A = 0.7; %area pre parachute
m = 118; %mass
%p = 1.2; %rho
C = 1; %drag
%% part a
v(1) = v0;
H(1) = h0;
t(1) = T;
n = 1;
%
% vc = sqrt(2*m*g/(p*C*A))
% tc = vc/g
% hc = vc*tc
while 1
if H(n) < 1043 %break when ground is reached
break
end
Hkm = H(end)/1000;
g = G*6356.766.^2/(6356.766+Hkm).^2;
p = 1.2241*exp(-(Hkm/11.661)-(Hkm/18.192)^2+(Hkm/29.235)^3);
vc = sqrt(2*m*g/(p*C*A));
tc = vc/g;
hc = vc*tc;
if n > 26000 %50 sec parachute Drag increase
A = 50;
C = 3.17;
end
%a(n) = -g - D*v(n)*abs(v(n));
a(n) = -g*(1-v(n)^2/((vc^2)));
%a(n) = g*(vc^2-v(n)^2)/(vc*cosh(t-t0/tc))+v0*sinh(t-t0/tc);
v(n+1) = v(n) + a(n)*T;
%v(n+1) = vc*(v0/vc)+tanh(t-t0/tc)/(1+v0/vc*tanh(t-t0/tc));
H(n+1) = H(n) + v(n)*T;
n = n+1;
t(n) = n/100;
end
ng = n-1;
tg = (n-1)*T;
a(end+1)=0;
vneg = -v;
aneg = -a;
plot(t,H,'r-');
xlabel('T')
ylabel('H')
title('H(t)')
legend('height')
grid on
[Vmax,Tmax] = max(vneg);
% Hmax??? neet to find the value of H @ Tmax

採用された回答

Scott MacKenzie
Scott MacKenzie 2021 年 10 月 24 日
Just use
H(Tmax)
BTW, the value is 28106.
  1 件のコメント
Chett Manly
Chett Manly 2021 年 10 月 24 日
Thanks man, I have been doing matlab all day and was a bit cooked.
It makes sense.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by