Hi i'm trying to run this function in simulink using matlab function block but i'm encountering this errors can anyone help me regarding this?
Mostrar comentarios más antiguos
function y = LINEARKALMAN(u)
V=10;
if(u(7)==0)
X=[0.1807;0];
Pxx=[0.01 0;0 0.01];
else
X=X2;
Pxx=Pxy;
end
theta=X(1);
phi=X(2);
A=[0,- u(6)*cos(phi) - u(5)*sin(phi);u(6)*cos(phi)*(tan(theta)^2 + 1) + u(5)*sin(phi)*(tan(theta)^2 + 1), u(5)*cos(phi)*tan(theta) - u(6)*sin(phi)*tan(theta)];
B=[0,cos(phi),-sin(phi);1, sin(phi)*tan(theta), cos(phi)*tan(theta)];
C=[cos(theta) + (100*V*u(5)*cos(theta))/981,0; sin(phi)*sin(theta) - (100*V*(u(4)*cos(theta) + u(6)*sin(theta)))/981, -cos(phi)*cos(theta); cos(phi)*sin(theta), cos(theta)*sin(phi) + (100*V*u(5)*sin(phi))/981];
R=[0.0016 0 0;0 0.0016 0;0 0 0.0016];
Q=[0.001 0;0 0.001];
phik=expm(A.*0.01);
v=[u(4);u(5);u(6)];
Y=[u(1);u(2);u(3)];
X1=phik*X+B*v;
Inno=Y-C*X1;
M=(phik*Pxx*phik')+Q;
S=(C*M*C')+R;
K=(M*C')/S;
X2=X1+K*Inno;
Pxy=(eye(2)-K*C)*M;
y=X2;

end
Respuestas (1)
Ryan Livingston
el 15 de Mzo. de 2015
0 votos
As the error states, the variables X2 and Pxy are undefined before they are used. They need to have definitions, i.e. assignments to them, or be passed as inputs to the MATLAB Function Block in order to be used on the RHS of an assignment.
Categorías
Más información sobre Simulink Functions en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!