my array don't return the true value
조회 수: 4 (최근 30일)
이전 댓글 표시
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
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!