ERROR: Array indices must be positive integers or logical values
4 views (last 30 days)
Show older comments
Drishya Dinesh
on 1 Apr 2021
Commented: Drishya Dinesh
on 1 Apr 2021
An error occurred while running the simulation and the simulation was terminated
Caused by:
- Error due to multiple causes.
- Array indices must be positive integers or logical values.
- Error in airshipsystemsimulation/Interpreted MATLAB Function5 while evaluating expression
%MATLAB FUNCTION CODE (USED WITHIN INTERPRETED MATLAB FUNCTION BLOCK WITH 9 INPUTS):
function op=airshipsyspgmoutqdot(u)
%inputs
ue=u(1);ve=u(2);we=u(3);
pe=u(4);qe=u(5);re=u(6);
phie=u(7);thetae=u(8);psie=u(9);
%%
%parameters
m=9.07;
B=72.2;
W=89;V=7.6;L=6;D=1.4;
a_z=-0.041;
Xx=1.12; Yy=7.25; Zz=7.25;
Kpdot=0;Mqdot=8.87;Nrdot=8.87;
Ix=2.19;Iy=18.85;Iz=18.76;
Ixz=0;
Xu=-10;Yv=-10;Zw=-10;Lp=-10;Mq=-10;Nr=-10;
Jx=Ix-Kpdot;Jy=Iy-Mqdot;Jz=Iz-Nrdot;Jxz=0;
mx=m-Xx;my=m-Yy;mz=m-Zz;
Tr=0.1;Tl=0.1;
%%
c1=cos(phie);c2=cos(thetae);c3=cos(psie);
s1=sin(phie);s2=sin(thetae);s3=sin(psie);
t2=tan(thetae);
qdot=0.0047*(-mz*we*qe+my*we*ve-m*a_z*pe*re-(W-B)*s2)+...
0.1004*((Jx-Jz)*pe*re+Jxz*((re).^2-(pe).^2)+m*a_z*(qe*we-re*ve)-W*a_z*s2-10+(Tr+Tl)*a_z);
op=qdot;
end
0 Comments
Accepted Answer
Walter Roberson
on 1 Apr 2021
That code looks okay, other than not being documented.
However, it does not have 9 inputs, and this structure would normally be called a MATLAB Function Block but not an Interpreted MATLAB Function block: the Interpreted MATLAB Function blocks referred to a block that can only accept a single expression (that could call functions.)
So potentially the fault is not this routine, but another block calling this routine.
More Answers (0)
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!