Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
error using==>vertcat

Subject: error using==>vertcat

From: zainah

Date: 21 Jun, 2011 04:53:05

Message: 1 of 2

Dear all,
This file has an error:
Error using ==> vertcat
All rows in the bracketed expression must have the same
number of columns.

which part should I correct it? Thanks.

clear all;
% Matrix
k=1;
A=[k 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 k 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0];

B=[0 0 0;...
      0 0 0;...
      0 0 0;...
      0 0 0;...
      0 0 0;...
      0 0 0;...
      1 0 0;...
      0 0 0;...
      0 1 0;...
      0 0 0;...
      0 0 1];
  
C= [0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0];

D = zeros(11,3);
% ctrb(A,B);
% obsv(A,C);

% Computing the Plant

Gss=ss(A,B,C,D)
Gsys=pck(A,B,C,D)
Gss.InputName= ['inputu2';'inputu3';'inputu4'];
Gss.OutputName=['y3 ';'y5';'y7 ';'y9 ';'y11'];
% Gss.OutputName= ['0 ';'y3 ';'0 ';'y5';'0 ';'y7 ';'0 ';'y9 ';'0';'y11'; '0'];
Gss.StateName= ['y2';'y3 ';'y4 ';'y5';'y6 ';'y7 ';'y8 ';'y9 ';'y10';'y11'; 'y12'];

% Gss.InputName= ['CollPitch';'LongPitch';'LatPitch ';'TailPitch'];
% Gss.OutputName=['u ';'w ';'q ';'theta';'v ';'p ';'phi ';'r ';'BetaC';'BetaS'];
% Gss.StateName= ['u ';'w ';'q ';'theta';'v ';'p ';'phi ';'r ';'BetaC';'BetaS'];
uA=[0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0;...
      0 0 0 0 0 0 0 0 0 0 0];
  
uB=[0 0 0;...
      0 0 0;...
      0 0 0;...
      0 0 0;...
      0 0 0;...
      0 0 0;...
      0 0 0;...
      0 0 0;...
      0 0 0;...
      0 0 0;...
      0 0 0];
  
% uA=zeros(11,11);
% uB=zeros(11,3);
p=[uA uB; zeros(size(C)) zeros(size(D))];
qi=rank(p);

[U,S,V] = svd(p);
Nstates=11; % n
Ninput=3; %nu
Noutput=5; %ny

L=U(1:Nstates,1:qi);
W=U(Nstates+1:Nstates+Noutput,1:qi);
R=(S(1:qi,1:qi)*V(1:qi,1:Nstates));
Z=(S(1:qi,1:qi)*V(1:qi,Nstates+1:Nstates+Ninput));

%uncertainty matrix
uGss=ss(A,[L B],[R;C],[zeros(qi,qi) Z;W D]);
uGsys=pck(A,[L B],[R;C],[zeros(qi,qi) Z;W D]);

Blk=[qi 0];
%Checking for controllability

% if rank(ctrb(Gss.A,Gss.B))==rank(Gss.A)
% disp('System is controllable')
% else
% error('System is not controllable')
% end

%Checking for observability

% if rank(obsv(Gss.A,Gss.C))==rank(Gss.A)
% disp('System is observable')
% disp(' ')
% else
% error('System is not observable')
% end


uGss=ss(A,[L B],[R;C],[zeros(qi,qi) Z;W D]);
uGsys=pck(A,[L B],[R;C],[zeros(qi,qi) Z;W D]);

Blk=[qi 0]

Subject: error using==>vertcat

From: Sadik

Date: 21 Jun, 2011 12:24:04

Message: 2 of 2

Hi Zainah,

The following should help you figure out the problem.

1. Copy and paste all your code into an m-file. Let's call that myScript.m
2. Before running your script, go to command window and type

dbstop if error

This will stop execution right at the erronous line.

3. If you find yourself within a built-in function, i.e. a function that you did not write, go to command window again and type

dbup

This will get you one level up to the caller function. If you are still not in your function, repeat dbup.

You can now move your mouse cursor to see the content of each matrix and hence the problem.

Best.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us