MATLAB: Attempted to access 0 element of data T. The valid index range is 1 to 1

access 0 element valid index rangematlab codersimulink

hello friends i have a problem
i have a simulation in simulink but when run simulation compile but then intro a debbug and appear this message "Attempted to access 0 element of data T. The valid index range is 1 to 1" why? this is my code
if true
function [wk1,pak1,pbk1,iak1,ibk1] = fcn(wk,pak,pbk,iak,ibk,uak,ubk)
%#codegen
Rs=14;
Ls=.400;
Lm=.377;
Rr=10.1;
Lr=.4128;
Np=2;
J=0.01;
Tl=1.1;
fv=0;
T=0.0001;
alpha=Rr/Lr;
alphad=1/(1+(T*alpha));
sigma=Ls-(Lm^2/Lr);
sigmad=(sigma+((alpha*alphad*T*Lm^2)/Lr));
betad=Lm/(sigmad*Lr);
gammad=(1-((Rs*T)/sigmad));
mu=(3*Lm*Np)/(2*J*Lr);
mud=mu*alphad;
wk1=wk-((fv/J)*T*wk)+(mud*T((pak*ibk)-(pbk*iak)))-((T/J)*Tl);
pak1=(alphad*((pak*cos(T*Np*wk))-(pbk*sin(T*Np*wk)))+(Lm*alpha*alphad*T*((iak*cos(T*Np*wk))-(ibk*sin(T*Np*wk)))));
pbk1=(alphad*((pak*sin(T*Np*wk))+(pbk*cos(T*Np*wk)))+(Lm*alpha*alphad*T*((iak*sin(T*Np*wk))+(ibk*cos(T*Np*wk)))));
iak1=(-(Lm*alpha*T*iak)+pak)*((betad*alphad*alphad)*(cos(T*Np*wk)- sin(T*Np*wk)))+((betad*alphad*pak)+(gammad*iak)+((T*uak)/sigmad));
ibk1=(-(Lm*alpha*T*ibk)+pbk)*((betad*alphad*alphad)*(sin(T*Np*wk)+ cos(T*Np*wk)))+((betad*alphad*pbk)+(gammad*iak)+((T*ubk)/sigmad));
end

Best Answer

Looks like a typo with all those parentheses... MATLAB thinks you're indexing into a variable named T -- for example, T(1).
I did a Ctrl+F of your post to find "T(" and found this line. The problem is highlighted in bold:
wk1=wk-((fv/J)*T*wk)+(mud* *T(* (pak*ibk)-(pbk*iak)))-((T/J)*Tl);
You probably missed a multiplication symbol ( * ) somewhere.