Simulink error: Attempt to access an element that was not defined before use
Mostrar comentarios más antiguos
Hello,
I have the following code in a Matlab function block in simulink:
function D0 = ComputeD0(q)
n=2;
base_att=q(1:3);
theta=q(4:n+1);
m_DEM=zeros(1,n+1);
vc=cell(1,n+1);
wi=cell(1,n+1);
Rot_0=cell(1,n+1);
I_DEM=cell(1,n+1);
coder.extrinsic('DEM_Dmatrix')
[m_DEM,vc,wi,Rot_0,I_DEM]=DEM_Dmatrix(theta,base_att);
% Matrix D
d=cell(1,n+1);
for i=1:n+1
d{i}=m_DEM(i)*vc{i}*vc{i}.'+wi{i}.'*Rot_0{1,i}*I_DEM{i}*Rot_0{1,i}.'*wi{i};
end
dd=cell(1,n+1);
dd{1}=d{1};
for i=2:n+1
dd{i}=d{i-1}+d{i};
if i==n+1
D0=dd{i};
end
end
When i run it i have the following error :
Attempt to access an element that was not defined before use.
Function 'D0 ' (#91.301.306), line 19, column 19:
"vc{i}"
Does anybody have an idea what it means? Thank you :)
1 comentario
Sudarshan Kolar
el 27 de Feb. de 2017
Can you share the contents of DEM_Dmatrix?
You can put a breakpoint at the line:
[m_DEM,vc,wi,Rot_0,I_DEM]=DEM_Dmatrix(theta,base_att);
And step your code from there to see the contents of 'vc'. This doc talks about debugging your MATLAB code.
Respuestas (0)
Categorías
Más información sobre Model Verification en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!