From: ravi on
Hi Jan,

I want it something like this in matlab:


X =[ 658 1072 96 103 ;760 1089 292 298]
>> X =
658 1072 96 103
760 1089 292 298

thanks ravi
From: Jan Simon on
Dear Ravi!


> I want it something like this in matlab:
> X = [658 1072 96 103 ;760 1089 292 298]
> >> X =
> 658 1072 96 103
> 760 1089 292 298

I'm getting more confused.
If I define this in Matlab:
X = [658 1072 96 103 ;760 1089 292 298]
I get immediately:
X =
658 1072 96 103
760 1089 292 298
Do you want something else?

In the first post you asked for this:
> I have a matrix X
> X =
> 658 1072
> 96 103
> 760 1089
> 292 298
> I wish INSTEAD to output like this:
> X = 658 1072 96 103
> 760 1089 292 298

Do you want to reorder the elements?
Perhaps:
reshape(permute(x', 2, 2, 2), [3, 1, 2]), 2, 4)

Jan
From: ravi on
Ok Jan,

I'll try to rephrase exactly what I am trying to do.

I have a matrix:
X = [658 1072 ;96 103 ;760 1089;292 298]

Now, Matlab outputs it like the following:

X =

658 1072
96 103
760 1089
292 298

However, my aim is to get X to be reshaped somehow like the following:

>> X =
658 1072 96 103
760 1089 292 298

If I can get a solution to solve this problem for an X matrix of any size this would be great.Hope this helps you out and thanks again for the help .

ravi
From: us on
"ravi " <ravi_071(a)hotmail.com> wrote in message <hu8qhb$pq1$1(a)fred.mathworks.com>...
> Hi guys,
>
> I have a matrix X
> X =
>
> 658 1072
> 96 103
> 760 1089
> 292 298
>
>
> I wish INSTEAD to output like this:
>
> X = 658 1072 96 103
> 760 1089 292 298
>
>
> Can anyone suggest something
>
>
> ravi

this does the col-row RESHAPEing

http://www.mathworks.com/matlabcentral/fileexchange/20255

us
From: Roger Stafford on
"ravi " <ravi_071(a)hotmail.com> wrote in message <hu8ubl$gt7$1(a)fred.mathworks.com>...
> i would like to do this in some kind off loop assuming X would get larger by 2 rows incrementally
> Ravi
>
> "ravi " <ravi_071(a)hotmail.com> wrote in message <hu8qhb$pq1$1(a)fred.mathworks.com>...
> > Hi guys,
> >
> > I have a matrix X
> > X =
> >
> > 658 1072
> > 96 103
> > 760 1089
> > 292 298
> >
> > I wish INSTEAD to output like this:
> >
> > X = 658 1072 96 103
> > 760 1089 292 298
> >
> > Can anyone suggest something
> > ravi
- - - - - - - - -
I gather you want to always end up with four columns and each row is made up of the elements from two successive rows of the original X. How about this:

X = reshape(X.',4,[]).';

Roger Stafford
First  |  Prev  | 
Pages: 1 2
Prev: MATLAB Mex Error
Next: progress bar and time display