COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Reshaping Matrices #2

• Email
• Follow

```??? 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.
```
 0
Reply kwenami (24) 8/1/2012 4:25:06 PM

See related articles to this posting

```
"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
http://www.mathworks.com

```
 0
Reply slord (13686) 8/1/2012 4:43:15 PM

1 Replies
39 Views

Similar Articles

12/9/2013 8:30:30 AM
page loaded in 42517 ms. (0)