Can you help me ? Indexing error

Y_beta=Yv;
N_beta=Nv;
Delta_r = [s-Y_beta / u0, 1-Yr / u0; -1*N_beta, s- Nr];
D_beta = [YdeltaR/u0, 1- Yr/u0; NdeltaR, s- Nr];
dr_appro=vpa(det(D_beta) ./ det(Delta_r) , 3);
disp('Beta transfer function:')
disp(dr_appro)
%ROLL DYNAMICS
RDra=vpa(LdeltaA ./ (s .*(s-Lp)) ,3);
disp('Roll angle transfer function:')
disp(RDra)
This is the error I obtained:
Error using sym/subsindex (line 853)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.
Error in sym/subsref (line 898)
R_tilde = builtin('subsref',L_tilde,Idx);
Error in Nicolas_Moujon_new (line 192)
dr_appro=vpa(det(D_beta) ./ det(Delta_r) , 3);
I don't know how to solve it ! I just have seen that it happens few times ago. I tried by myself but unsuccessfully.
Thank you very much in advance for your help !!
Nicolas

2 Comments

Can you attach the whole code?
Thanks for your reply.
You will find it below:
clear all; clc;
% PARAMETERS
m=7392;
g=9.81;
Xcg=0.07;
Ixx=4480.8;
Iyy=73999.5;
Izz=75390.8;
z=10668;
rho=0.379;
u0=267;
mach=0.9;
theta0=2.86*0.0174533;
q=(1/2)*(rho)*(u0)^2;
S=18.22;
b=6.69;
c=2.91;
a=2.45;
O=0.92;
CL0=0.735;
CD0=0.263;
CTx0=0.025;
Cm0=0;
Cmt0=0;
Clb=-0.175;
Clp=-0.285;
Clr=0.265;
CldeltaA=0.039;
CldeltaR=0.045;
Cnb=0.5;
Cnp=-0.14;
Cnr=-0.75;
CndeltaA=0.0042;
CndeltaR=-0.16;
Cyb=-1.17;
Cyp=0;
Cyr=0;
CydeltaA=0;
CydeltaR=0.208;
Q=(1/2)*rho*u0^2;
Yv=(Q*S*Cyb)/(m*u0);
Yp=(Q*S*b*Cyp)/(2*m*u0);
Yr=(Q*S*b*Cyr)/(2*m*u0);
Lv=(Q*S*b*Clb)/(Ixx*u0);
Lp=(Q*S*b^2*Clp)/(2*Ixx*u0);
Lr=(Q*S*b^2*Clr)/(2*Ixx*u0);
Nv=(Q*S*b*Cnb)/(Izz*u0);
Np=(Q*S*b^2*Cnp)/(2*Izz*u0);
Nr=(Q*S*b^2*Cnr)/(2*Izz*u0);
YdeltaR=((q*S)/(m*u0))*CydeltaR;
YdeltaA=((q*S)/(m*u0))*CydeltaA;
LdeltaR=((q*S*b)/(Ixx*u0))*CldeltaR;
LdeltaA=((q*S*b)/(Ixx*u0))*CldeltaA;
NdeltaR=((q*S*b)/(Izz*u0))*CndeltaR;
NdeltaA=((q*S*b)/(Izz*u0))*CndeltaA;
% MATRIX
A=[Yv Yp -u0+Yr g*cosd(theta0); Lv Lp Lr 0; Nv Np Nr 0; 0 1 0 0];
print(A)
% CHARACTERISTIC EQUATION
P=charpoly(A);
print(P)
% EIGENVALUES OF THE SYSTEM
[vect_p,val_p]=eig(A);
[Wn,Zeta]=damp(A);
% CURVES
n=10;
n1=80000;
n2=1200;
% ROLLING MODE
figure(1);
R=@(t) vect_p(1,3)*exp(val_p(3,3)*t);
R2=@(t) vect_p(2,3)*exp(val_p(3,3)*t);
R3=@(t) vect_p(3,3)*exp(val_p(3,3)*t);
R4=@(t) vect_p(4,3)*exp(val_p(3,3)*t);
fplot(R,[0 n]); hold on;
fplot(R2,[0 n]);
fplot(R3,[0 n]);
fplot(R4,[0 n]);
legend('Side velocity','roll rate','Yaw rate','Side angle')
title('Rolling mode');
xlabel('Time (s)')
ylabel('State variable')
% SPIRAL MODE
figure(2);
S=@(t) vect_p(1,4)*exp(-val_p(4,4)*t);
S2=@(t) vect_p(2,4)*exp(-val_p(4,4)*t);
S3=@(t) vect_p(3,4)*exp(-val_p(4,4)*t);
S4=@(t) vect_p(4,4)*exp(-val_p(4,4)*t);
fplot(S,[0 n1]); hold on;
fplot(S2,[0 n1]);
fplot(S3,[0 n1]);
fplot(S4,[0 n1]);
legend('Side velocity','roll rate','Yaw rate','Side angle')
title('Spiral mode');
xlabel('Time (s)')
ylabel('State variable')
% DUTCH ROLL MODE
figure(3);
DR=@(t) vect_p(1,1)*exp(val_p(1,1)*t)+vect_p(1,2)*exp(val_p(2,2)*t);
DR2=@(t) vect_p(2,1)*exp(val_p(1,1)*t)+vect_p(2,2)*exp(val_p(2,2)*t);
DR3=@(t) vect_p(3,1)*exp(val_p(1,1)*t)+vect_p(3,2)*exp(val_p(2,2)*t);
DR4=@(t) vect_p(4,1)*exp(val_p(1,1)*t)+vect_p(4,2)*exp(val_p(2,2)*t);
fplot(DR,[0 n2]); hold on;
fplot(DR2,[0 n2]);
fplot(DR3,[0 n2]);
fplot(DR4,[0 n2]);
legend('Side velocity','roll rate','Yaw rate','Side angle')
title('Dutch Roll mode');
xlabel('Time (s)')
ylabel('State variable')
%TRANSFERT FUNCTION
I=eye(4); %matrice identite 4x4
syms s
det=det(s*I-A); %determinant
adj=adjoint(s*I-A); %adjacent
%AILERON
Ai=[YdeltaA; LdeltaA; NdeltaA; 0]; %matrice aileron
TfAi=adj/det * Ai;
aiss=vpa(TfAi(3),3); %Side Slip
airr=vpa(TfAi(4),3); %Roll Rate
aira=vpa(TfAi(1),3); %Roll Angle
aiyr=vpa(TfAi(2),3); %Yaw Rate
disp('Side slip function for the control of ailerons:')
disp(aiss)
disp('Roll rate function for the control of ailerons:')
disp(airr)
disp('Roll angle function for the control of ailerons:')
disp(aira)
disp('Yaw rate function for the control of ailerons:')
disp(aiyr)
%RUDDER
Ru=[YdeltaR; LdeltaR; NdeltaA; 0];
TfRu = adj/det * Ru;
russ=vpa(TfRu(3),3); %Side Slip
rurr=vpa(TfRu(4),3); %Roll Rate
rura=vpa(TfRu(1),3); %Roll Angle
ruyr=vpa(TfRu(2),3); %Yaw Rate
disp('Side slip function for the control of the rudder:')
disp(russ)
disp('Roll rate function for the control of the rudder:')
disp(rurr)
disp('Roll angle function for the control of the rudder:')
disp(rura)
disp('Yaw rate function for the control of the rudder:')
disp(ruyr)
%DUTCH ROLL APPRO
Y_beta=Yv;
N_beta=Nv;
Delta_r = [s-Y_beta / u0, 1-Yr / u0; -1*N_beta, s- Nr];
D_beta = [YdeltaR/u0, 1- Yr/u0; NdeltaR, s- Nr];
dr_appro=vpa(det(D_beta) ./ det(Delta_r) , 3);
disp('Beta transfer function:')
disp(dr_appro)
%ROLL DYNAMICS
RDra=vpa(LdeltaA ./ (s .*(s-Lp)) ,3);
disp('Roll angle transfer function:')
disp(RDra)

Sign in to comment.

 Accepted Answer

Steven Lord
Steven Lord on 29 May 2020
You've defined a variable named det in your code. Because of this you cannot use the det function. Attempting to call det (the function) will instead be interpreted as an attempt to index into det (the variable.)
Rename that variable.

1 Comment

Thank you very much for your reply ! The code is working now.

Sign in to comment.

More Answers (1)

darova
darova on 29 May 2020
THe problem

3 Comments

I corrected it that way:
%TRANSFERT FUNCTION
I=eye(4); %matrice identite 4x4
syms s
det=det((s*I)-A); %determinant
adj=adjoint((s*I)-A); %adjacent
But I still have those errors:
Error using sym/subsindex (line 853)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.
Error in sym/subsref (line 898)
R_tilde = builtin('subsref',L_tilde,Idx);
Error in Nicolas_Moujon_new (line 192)
dr_appro=vpa(det(D_beta) ./ det(Delta_r) , 3);
Thank you for your help
I don't see any difference
So, what do I have to change ?
Thanks

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Release

R2020a

Community Treasure Hunt

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

Start Hunting!