getting error of matrix dimension

6 次查看(过去 30 天)
Aniket
Aniket 2013-3-19
Hello
Trying to use kalman command and getting error in designing of weighting matrix QN.
i am getting following error
Error using horzcat
CAT arguments dimensions are not consistent.
Error in LQG_controller_mat (line 28)
QN=[QW f]
my code is
************************
clear all; clc; close all
load sec_sumsin_ABCDmatrix.mat % data As,Bs,Cs,Ds
syss=ss(As,Bs,Cs,Ds,0.001);
syssc=d2c(syss,'tustin'); % convert from discrete to continuous
[Asc,Bsc,Csc,Dsc]=ssdata(syssc);
nx=10; % states
ny=1; % output
nu=1; % input
M=diag([1.8108e0*ones(1,ny)]);
QX=Csc'*M*Csc;
QU=diag([3.9805e-8*ones(1,nu)]);
Kc= lqr(syssc,QX,QU)
QW=1*eye(nx);
f=zeros(1,nx);
QN=[QW f]
QV=1*eye(ny);
g=zeros(1,nx);
RN=[QV g]
L= kalman(syssc,QN,RN)

回答(1 个)

Image Analyst
Image Analyst 2013-3-19
You need to learn how to use the debugger. Set a breakpoint on this line:
QN=[QW f];
Then when it stops there, type this into the command window:
size(QW)
size(f)
The first number that it prints out for each is the number of rows in that variable. The rows must have the same value or else you can't stitch those arrays together horizontally.
  2 个评论
Aniket
Aniket 2013-3-19
yeah i have done that and getting size (QW) = 10 10
and size(f) = 1 10
so i have changed f= zeros(10,10)
now i am getting error
Error using ss/kalman (line 102) In the "kalman(SYS,QN,RN,NN,...)" command, QN must be a real square matrix with at most 1 rows.
here my QW is 10* 10 matrix and f is 10 * 10 matrix
and i want QN = [QW f] as a square matrix ?
Image Analyst
Image Analyst 2013-3-19
I don't know what all those variables are supposed to mean and how kalman interprets them. All I know is that you can't stitch a 1 row matrix side by side with a 10 row matrix. I think you need to understand what's going on and not just change some f variable to allow the stitching to work when that might break something else that depends on f being 1 row tall.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by