Thread Subject:
Reshaping Matrices

Subject: Reshaping Matrices

From: Kwen

Date: 1 Aug, 2012 16:25:10

Message: 1 of 2

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

Error in ==> Energy_Yield_Model at 210
        X(j,:)=[X(1:j-1,:) X(j+1:end,:)];
 
>> size(X(1:j-1,:))

ans =
          1 1480

>> size(X(j+1:end,:))

ans =
         715 1480

I'm trying to loop through for each j that falls under an if statement and if it does, remove a row from my matrix at that point. What am I doing wrong or not understanding here? my columns are the same size and the dimensions are the same so shouldn't this work? I am only changing in the j or rows direction.

Subject: Reshaping Matrices

From: Steven_Lord

Date: 1 Aug, 2012 16:43:18

Message: 2 of 2



"Kwen " <kwenami@hotmail.com> wrote in message
news:jvbl96$nkh$1@newscl01ah.mathworks.com...
> ??? Error using ==> horzcat
> CAT arguments dimensions are not consistent.
>
> Error in ==> Energy_Yield_Model at 210
> X(j,:)=[X(1:j-1,:) X(j+1:end,:)];
>
>>> size(X(1:j-1,:))
>
> ans = 1 1480
>
>>> size(X(j+1:end,:))
>
> ans =
> 715 1480
>
> I'm trying to loop through for each j that falls under an if statement and
> if it does, remove a row from my matrix at that point. What am I doing
> wrong or not understanding here? my columns are the same size and the
> dimensions are the same so shouldn't this work? I am only changing in the
> j or rows direction.

Compare:

x1 = [1 2];
x2 = [3 4; 5 6; 7 8];
x3 = [x1, x2] % DOES NOT work
x4 = [x1; x2] % DOES work

Read the Description sections (they're short, only a few sentences each) of
the documentation pages for HORZCAT and VERTCAT to learn about the
differences between the lines starting with x3 and x4 above.

http://www.mathworks.com/help/techdoc/ref/horzcat.html

http://www.mathworks.com/help/techdoc/ref/vertcat.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us