kalman function from Control System Toolbox™ missing Nu value

2 views (last 30 days)
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)
  2 Comments
Craig
Craig on 20 Jul 2011
Hi Paulo,
I ran the code you posted in MATLAB version R2008b and it ran to completion fine. The variable Nu is initialized on line 101 of ss/kalman
Nu = md-Nw;
>> edit ss.kalman %to bring up the kalman function in the editor.
Can you verify that this is in your version?
Paulo Silva
Paulo Silva on 20 Jul 2011
Thank you very much Craig, the line 101 was empty on my kalman function from MATLAB 2008b, please copy and post your comment to an answer so I can accept it and give you a vote.

Sign in to comment.

Accepted Answer

Craig
Craig on 21 Jul 2011
Hi Paulo,
I ran the code you posted in MATLAB version R2008b and it ran to completion fine. The variable Nu is initialized on line 101 of ss/kalman
Nu = md-Nw;
>> edit ss.kalman %to bring up the kalman function in the editor.
Can you verify that this is in your version?
  1 Comment
Sean de Wolski
Sean de Wolski on 21 Jul 2011
Confirmed 2009b:
>>edit kalman
Lines 98:101
% Validate Qn,Rn,Nn
[Nw,Nw2] = size(qn);
[Ny,Ny2] = size(rn);
Nu = md-Nw;

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!