필터 지우기
필터 지우기

my array don't return the true value

조회 수: 1 (최근 30일)
tuan nguyen minh
tuan nguyen minh 2021년 10월 26일
댓글: tuan nguyen minh 2021년 10월 28일
i use this function:
function f =hpt(u1,u2,u3,u4,u5)
global P X G m Y mz_0 Cy Xt Xf mz_delta_b delta_b mz_omega_z b_a q S I_z;
f=[ (P*cos(-0.014)-X-G*sin(u2))/m,...
(P*sin(-0.014)+Y-G*cos(u2))/(m*u1),...
((mz_0+Cy*(Xt-Xf)+mz_delta_b*delta_b+mz_omega_z*b_a*(u3/u1))*q*S*b_a)/I_z,...
u3,...
u1*sin(u2)
];
end
with the input
gt_dau(1,:)=[V small_theta omega_z theta H] ;
k1=hpt(gt_dau(ii,1),gt_dau(ii,2),gt_dau(ii,3),gt_dau(ii,4),gt_dau(ii,5));
value of returned k1:
-0.000158173208030319 -0.000121964317063585 0 0 0
the third component is not right, not 0 but -0.000121965, so i wonder what i am doing wrong here?
  댓글 수: 2
Jan
Jan 2021년 10월 26일
We cannot run your code. Global variables are a shot in the knee of the programmer, so avoid them strictly. They are impeding the debugging of code massively.
Use the debugger to step through your code line by line. Then you will find out, why the value differ from your expectations.
Remember: All we see here is code, which we cannot run due to the missing input values. Even if the values are defined, we do not know, why you expect anything else.
tuan nguyen minh
tuan nguyen minh 2021년 10월 28일
Sorry, i do the calculation again and found out that matlab calculates right and I'm wrong. Thanks for your attention

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by