필터 지우기
필터 지우기

ODE45 How to use atmosisa function with Height function as Input?

조회 수: 5 (최근 30일)
Hafizuddin Bin Mohd Lowhim
Hafizuddin Bin Mohd Lowhim 2020년 5월 27일
편집: Hafizuddin Bin Mohd Lowhim 2020년 5월 27일
Hello,
I need help to configure how to use atmosisa function if we need to use height function h(t) as input? In this ODE45, I set variable z to be z(1), z(2), z(3) and z(4). z(2) is the height variable. When I put height to be 1000m, the code does work but when I put in as z(2) as input, it gives error.
Density.m
function rho=density()
[~, ~, ~, rho]=atmosisa(z(2));
end
rhs_trajectory
function dz = rhs_trajectory(z,g,F,F_d,m,gamma)
x = z(1);
y = z(2);
v_x = z(3);
v_y = z(4);
dx = v_x;
dy = v_y;
dv_x = ((F-F_d)/m)*cos(gamma)-m*sin(gamma);
dv_y = ((F-F_d)/m)*sin(gamma)-g;
dz = [dx; dy; dv_x; dv_y];
end
I attached other necessery function for reference. Please help me.
  댓글 수: 1
darova
darova 2020년 5월 27일
The question is unclear
  • You are passing some argument into atmosisa, but not passing into density
function rho=density() % z(2) should an argument
[~, ~, ~, rho]=atmosisa(z(2));
end
  • i don't see you use density function. Where do you want to use it?

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2020년 5월 27일
but when I put in as z(2) as input, it gives error
That is most likely because you do not pass it as an argument to your ‘density’ function.
Try this:
function rho=density(x)
[~, ~, ~, rho]=atmosisa(x);
end
(I also do not see where you called it in your ‘rhs_trajectory’ function.)
I do not have the Aerospace Toolbox, so I cannot test this directly. However the problem appears to be obvious.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by