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:
Multirow to One Column

Subject: Multirow to One Column

From: Stavros

Date: 15 Sep, 2010 08:04:05

Message: 1 of 3

hello all,

I have a matrix A=[49x14]

I try to make a loop to get each row as column :

newA=[A(1,1:12)'; A(2,1:12)';.... ;A(49,1:12)']

i tried:

for i=1:49
     newA=[A(i,1:12)';]
end

but dont work

I believe its easy but i cant get it....
Any suggestions ??

Ty all for your time to even read this post :)

Subject: Multirow to One Column

From: Roger Stafford

Date: 15 Sep, 2010 08:24:07

Message: 2 of 3

"Stavros " <stavrosana@aegean.gr> wrote in message <i6pull$of9$1@fred.mathworks.com>...
> hello all,
>
> I have a matrix A=[49x14]
>
> I try to make a loop to get each row as column :
>
> newA=[A(1,1:12)'; A(2,1:12)';.... ;A(49,1:12)']
>
> i tried:
>
> for i=1:49
> newA=[A(i,1:12)';]
> end
>
> but dont work
>
> I believe its easy but i cant get it....
> Any suggestions ??
>
> Ty all for your time to even read this post :)
- - - - - - -
 newA = reshape(A(:,1:12).',[],1);

  (Note: I would have written newA = reshape(A.',[],1); but you used only the first 12 elements out of 14 of each row. Was that a typo?)

Roger Stafford

Subject: Multirow to One Column

From: Stavros

Date: 15 Sep, 2010 09:10:19

Message: 3 of 3

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i6pvr7$9tf$1@fred.mathworks.com>...
> "Stavros " <stavrosana@aegean.gr> wrote in message <i6pull$of9$1@fred.mathworks.com>...
> > hello all,
> >
> > I have a matrix A=[49x14]
> >
> > I try to make a loop to get each row as column :
> >
> > newA=[A(1,1:12)'; A(2,1:12)';.... ;A(49,1:12)']
> >
> > i tried:
> >
> > for i=1:49
> > newA=[A(i,1:12)';]
> > end
> >
> > but dont work
> >
> > I believe its easy but i cant get it....
> > Any suggestions ??
> >
> > Ty all for your time to even read this post :)
> - - - - - - -
> newA = reshape(A(:,1:12).',[],1);
>
> (Note: I would have written newA = reshape(A.',[],1); but you used only the first 12 elements out of 14 of each row. Was that a typo?)
>
> Roger Stafford

Ty Roger ...

That was that i needed ..
newA = reshape(A.',[],1)

I was trying the reshape also ,but i wasn't putting '.' !!!

Ty for you time

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