필터 지우기
필터 지우기

getting error of matrix dimension

조회 수: 8 (최근 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에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by