For some strange reason the kalman function doesn't work on my MATLAB 2008b even with examples from the MATLAB documentation it fails
??? Undefined function or variable'Nu'.Error in ==> ss.kalman at 136 known = 1:Nu;
After editing the kalman function I discovered that the Nu variable isn't initialized but it's used many times on the code, thus the error.
Can someone with the Control System Toolbox™ check it out?
Example — Designing an LQG Servo Controller , this is from MATLAB 2008b documentation, it should work but it doesn't because of the missing Nu initialization on the kalman function.
A = [0 1 0;0 0 1;1 0 0]; B = [0.3 1;0 1;-0.3 0.9];G = [-0.7 1.12; -1.17 1; .14 1.5];C = [1.9 1.3 1]; D = [0.53 -0.61];H = [-1.2 -0.89];sys = ss(A,[B G],C,[D H])%Construct the optimal state-feedback gain using the given cost function by typing the following commands:
nx = 3; %Number of states
ny = 1; %Number of outputs
Q = blkdiag(0.1*eye(nx),eye(ny));R = [1 0;0 2];K = lqi(ss(A,B,C,D),Q,R)%Construct the Kalman state estimator using the given noise covariance data by typing the following commands:
Qn = [4 2;2 1]; Rn = 0.7;kest = kalman(sys,Qn,Rn);%Connect the Kalman state estimator and the optimal state-feedback gain to form the LQG servo controller by typing the following command:
trksys = lqgtrack(kest,K)
Best Answer