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: CAT arguments dimensions are not consistent

Subject: ERROR: CAT arguments dimensions are not consistent

From: Amanda Rafuse

Date: 29 Jul, 2008 13:25:04

Message: 1 of 7

I am trying to perform a regression on a bunch of data I
have, and this is a portion of my code with the regression
in it which my boss gave me to use:


%Perform the regression on the size vs. settling data
x = [ones(length(sizes),3) log(sizes)];
y = log (ws);
[b,bint,r,rint,stats] = regress (y,x, 0.05);


when I run my code it gives me this error:


??? Error using ==> horzcat
CAT arguments dimensions are not consistent.

Error in ==> MINS3_sizesettling_yeardays_new2 at 86
x = [ones(length(sizes),3) log(sizes(:,3))];


Can anyone offer any help? I would appreciate it!!
- Amanda

Subject: ERROR: CAT arguments dimensions are not consistent

From: Ian Clarkson

Date: 29 Jul, 2008 14:57:02

Message: 2 of 7

"Amanda Rafuse" <rafusea@dal.ca> wrote in message
<g6n5ng$sgt$1@fred.mathworks.com>...
> I am trying to perform a regression on a bunch of data I
> have, and this is a portion of my code with the regression
> in it which my boss gave me to use:
>
>
> %Perform the regression on the size vs. settling data
> x = [ones(length(sizes),3) log(sizes)];
> y = log (ws);
> [b,bint,r,rint,stats] = regress (y,x, 0.05);
>
>
> when I run my code it gives me this error:
>
>
> ??? Error using ==> horzcat
> CAT arguments dimensions are not consistent.
>
> Error in ==> MINS3_sizesettling_yeardays_new2 at 86
> x = [ones(length(sizes),3) log(sizes(:,3))];
>
>
> Can anyone offer any help? I would appreciate it!!
> - Amanda

you should make sure of the sizing of your arrays. you're
trying to horizontally concatenate two arrays into x: your
array of ones and your log array. however, to horizontally
concatenate two arrays they must have the same number of
dimensions and the same number of columns.

run the following two commands:

size(ones(length(sizes),3))
size(log(sizes(:,3)))

i expect you'll find the dimensions aren't what you thought
they would be, and you're trying to connect them into the x
variable. once you figure out the problem with sizing (you
probably forgot to take a transpose or something) you should
be fine.

Subject: ERROR: CAT arguments dimensions are not consistent

From: Amanda Rafuse

Date: 6 Aug, 2008 18:43:02

Message: 3 of 7

"Ian Clarkson" <ovoidkumquat@hotmail.com> wrote in message
<g6nb3u$7d4$1@fred.mathworks.com>...
> "Amanda Rafuse" <rafusea@dal.ca> wrote in message
> <g6n5ng$sgt$1@fred.mathworks.com>...
> > I am trying to perform a regression on a bunch of data
I
> > have, and this is a portion of my code with the
regression
> > in it which my boss gave me to use:
> >
> >
> > %Perform the regression on the size vs. settling data
> > x = [ones(length(sizes),3) log(sizes)];
> > y = log (ws);
> > [b,bint,r,rint,stats] = regress (y,x, 0.05);
> >
> >
> > when I run my code it gives me this error:
> >
> >
> > ??? Error using ==> horzcat
> > CAT arguments dimensions are not consistent.
> >
> > Error in ==> MINS3_sizesettling_yeardays_new2 at 86
> > x = [ones(length(sizes),3) log(sizes(:,3))];
> >
> >
> > Can anyone offer any help? I would appreciate it!!
> > - Amanda
>
> you should make sure of the sizing of your arrays. you're
> trying to horizontally concatenate two arrays into x: your
> array of ones and your log array. however, to horizontally
> concatenate two arrays they must have the same number of
> dimensions and the same number of columns.
>
> run the following two commands:
>
> size(ones(length(sizes),3))
> size(log(sizes(:,3)))
>
> i expect you'll find the dimensions aren't what you
thought
> they would be, and you're trying to connect them into the
x
> variable. once you figure out the problem with sizing (you
> probably forgot to take a transpose or something) you
should
> be fine.
>
>
>



I ran the commands as you suggested and it gave me this:

size(ones(length(sizes),3))
 size(log(sizes(:,3)))

ans =

        1471 3


ans =

     1 1

so my problem lies with the log of sizes then? i still
can't figure out what i need to do from here. This is
obviously telling me that they aren't the same length, but
i am not sure how to fix it.

I don't know my way around MATLAB enough yet to be able to
fix what i am sure are these very simple problems, so any
help is much appreciated.

Amanda :)

Subject: ERROR: CAT arguments dimensions are not consistent

From: Ian Clarkson

Date: 6 Aug, 2008 21:20:03

Message: 4 of 7

"Amanda Rafuse" <rafusea@dal.ca> wrote in message
<g7crbm$d5d$1@fred.mathworks.com>...
> "Ian Clarkson" <ovoidkumquat@hotmail.com> wrote in message
> <g6nb3u$7d4$1@fred.mathworks.com>...
> > "Amanda Rafuse" <rafusea@dal.ca> wrote in message
> > <g6n5ng$sgt$1@fred.mathworks.com>...
> > > I am trying to perform a regression on a bunch of data
> I
> > > have, and this is a portion of my code with the
> regression
> > > in it which my boss gave me to use:
> > >
> > >
> > > %Perform the regression on the size vs. settling data
> > > x = [ones(length(sizes),3) log(sizes)];
> > > y = log (ws);
> > > [b,bint,r,rint,stats] = regress (y,x, 0.05);
> > >
> > >
> > > when I run my code it gives me this error:
> > >
> > >
> > > ??? Error using ==> horzcat
> > > CAT arguments dimensions are not consistent.
> > >
> > > Error in ==> MINS3_sizesettling_yeardays_new2 at 86
> > > x = [ones(length(sizes),3) log(sizes(:,3))];
> > >
> > >
> > > Can anyone offer any help? I would appreciate it!!
> > > - Amanda
> >
> > you should make sure of the sizing of your arrays. you're
> > trying to horizontally concatenate two arrays into x: your
> > array of ones and your log array. however, to horizontally
> > concatenate two arrays they must have the same number of
> > dimensions and the same number of columns.
> >
> > run the following two commands:
> >
> > size(ones(length(sizes),3))
> > size(log(sizes(:,3)))
> >
> > i expect you'll find the dimensions aren't what you
> thought
> > they would be, and you're trying to connect them into the
> x
> > variable. once you figure out the problem with sizing (you
> > probably forgot to take a transpose or something) you
> should
> > be fine.
> >
> >
> >
>
>
>
> I ran the commands as you suggested and it gave me this:
>
> size(ones(length(sizes),3))
> size(log(sizes(:,3)))
>
> ans =
>
> 1471 3
>
>
> ans =
>
> 1 1
>
> so my problem lies with the log of sizes then? i still
> can't figure out what i need to do from here. This is
> obviously telling me that they aren't the same length, but
> i am not sure how to fix it.
>
> I don't know my way around MATLAB enough yet to be able to
> fix what i am sure are these very simple problems, so any
> help is much appreciated.
>
> Amanda :)

so it appears that you're trying to run some kind of linear
regression on some data. a helpful value to have would be
size(sizes). it looks like it has one long dimension of
1471, but since you've used the length command it could be
any number of dimensions. this command:

log(sizes(:,3))

will take the log of all the values in the third column of
your sizes array (assuming it's two-dimensional). however,
it appears that there is only one value in that location. my
guess would be that your data is actually not in column form
as you assume it is and that it is in fact a 3x1471 array
not a 1471x3 array as you've written here. in that case, try
doing:

log(sizes(3,:))

... instead. otherwise, just keep track of the sizes of your
arrays and plan out exactly what matrices you're trying to
create before you write the code. that way you can make sure
everything is the correct dimension ahead of time. it's easy
to get caught up in the code and forget about the dimensions
of your matrices, so take a look at them at each step, break
the problem up into smaller problems, and make sure you're
doing everything correctly along the way.

Subject: CAT arguments dimensions are not consistent

From: Francesca Vannini

Date: 23 Jun, 2010 21:43:05

Message: 5 of 7

Hello,
I'm using MPT Studio to generate a controller for a system. I wrote the System Dynamics, the System Constraints, the Penalties, the Reference point, the Prediction horizon; when I press the buttom Generate Controller, the message "CAT arguments dimensions are not consistent" appears on my screen. What does it mean? What have I to do? Moreover, when the controller is generated, how is it possible to access the regions (I tried to load an example and managed only to see a graph by pressing Plot Controller Regions and Plot Control Law)? I mean, is it possible to have an analythic description of the regions and of the Control Law? Thanks a lot to anyone who will be so kind to answer me!

Subject: CAT arguments dimensions are not consistent

From: Walter Roberson

Date: 23 Jun, 2010 22:24:52

Message: 6 of 7

Francesca Vannini wrote:
> when I press the buttom Generate
> Controller, the message "CAT arguments dimensions are not consistent"
> appears on my screen. What does it mean?

cat() is used to concatenate lists into larger lists, along any given axis.
Along the first axis is also known as vertcat(), along the second axis is also
known as horzcat(). Inside the [] list constructor, space or the "," (comma)
indicates horzcat and the ";" (semi-colon) indicates vertcat() .

[1 2; 3, 4, 5]

would be an example of attempting to vertcat(horzcat(1,2),horzcat(3,4,5))
However, this would fail because the "arguments dimensions are not consistent"
because you cannot concatenate a row with 3 elements to the bottom of a row
with 2 elements.


You should check carefully over any [] constructor you have, looking at all of
the commas and semi-colons and making sure that you use comma when you want to
create a horizontal row and you use semi-colon when you want to move on to the
next horizontal row, and that you have the same number of elements in all of
your rows.

Subject: CAT arguments dimensions are not consistent

From: Francesca Vannini

Date: 24 Jun, 2010 17:10:08

Message: 7 of 7

Sorry, I tried to check but I didn't manage to find what's wrong... the system I load as "Model" in MPT Studio is


sysStruct.A = [0, 0, 0, 0, 0, 0, 0;1, 0, 0, 0, 0, 0, 0;0, 1, 0, 0, 0, 0, 0;0, 0, 1, 0, 0.8, 0.04, 0;0, 0, 0, 0, 0.06, 0.9, 0;0, 0, 0, 0, 0, 0, 1];
sysStruct.B = [0.8;0.04;0;0;0;0;0];
sysStruct.C = [0, 0, 0, 0, 0.0005, 0.8, 0;0, 0, 0, 0, 0, 0, 1];
sysStruct.D = [0;0];
sysStruct.ymin = [-200, -20000000];
sysStruct.ymax = [200, 20000000];
sysStruct.umin = -15;
sysStruct.umax = 10;
sysStruct.dumin = -15;
sysStruct.dumax = 10;
sysStruct.dymin = [-50; -1000000];
sysStruct.dymax = [50; 1000000];

and the settings I load as "Problem" in MPT Studio are


probStruct.norm = 1;
probStruct.N = 1;
probStruct.subopt_lev = 0;
probStruct.Q = [1, 3, 5, 7, 8, 3, 7;1, 3, 5, 7, 8, 3, 7;1, 3, 5, 7, 8, 3, 7;1, 3, 5, 7, 8, 3, 7;1, 3, 5, 7, 8, 3, 7;1, 3, 5, 7, 8, 3, 7;1, 3, 5, 7, 8, 3, 7];
probStruct.R = 8;
probStruct.Qy = [6, 1 ; 1, 5];
probStruct.y0bounds = [0, 0; 0, 0];
probStruct.yref = [9;3];
probStruct.tracking = 0;

(for the moment I chose an arbitrary combinations of numbers)
These are the M-files Matlab saved, corresponding to what I wrote on MPT Studio... It says "CAT arguments dimensions are not consistent"...what can I do?

Thanks a lot!

Tags for 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