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

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

 채택된 답변

Sebastian Castro
Sebastian Castro 2015년 2월 25일

0 개 추천

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.

추가 답변 (1개)

jose raul valenzuela
jose raul valenzuela 2015년 2월 25일
편집: jose raul valenzuela 2015년 2월 25일

0 개 추천

thanks a lot yes i have a problema T a its a constant and i need multiply wk1=wk-((fv/J)*T*wk)+(mud*T((pak*ibk)-(pbk*iak)))-((T/J)*Tl);

카테고리

도움말 센터File Exchange에서 Configure and View Diagnostics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by