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

조회 수: 5 (최근 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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by