my array don't return the true value
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Jan
am 26 Okt. 2021
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.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!