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:
reshape a vector , split a vector

Subject: reshape a vector , split a vector

From: Jose

Date: 11 Jun, 2010 21:09:04

Message: 1 of 4

Hello to everyone, i have got this vector and i want to split it in blocks 0f 3 elements:


noise = 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 1


round(length(noise)/3)=9


 x=reshape(noise(1:27),9,[])

x =

     1 1 0
     1 1 0
     1 1 0
     1 0 1
     0 0 1
     0 0 1
     0 1 1
     1 1 1
     1 1 1

But the problem is that i am interested in this vector:

x' =111
      100
      011
      111
      000
       111
       000
       111
       111

How can transform x in x'?

Thanks in advance.

Subject: reshape a vector , split a vector

From: jrenfree

Date: 11 Jun, 2010 21:42:13

Message: 2 of 4

On Jun 11, 2:09 pm, "Jose " <jose.l.v...@gmail.com> wrote:
> Hello to everyone, i have got this vector and i want to split it in blocks 0f 3 elements:
>
> noise = 1     1     1     1     0     0     0     1     1     1     1     1     0     0     0     1     1     1     0     0     0     1     1     1     1     1     1     1
>
> round(length(noise)/3)=9
>
>  x=reshape(noise(1:27),9,[])
>
> x =
>
>      1     1     0
>      1     1     0
>      1     1     0
>      1     0     1
>      0     0     1
>      0     0     1
>      0     1     1
>      1     1     1
>      1     1     1
>
> But the problem is that i am interested in this vector:
>
> x' =111
>       100
>       011
>       111
>       000
>        111
>        000
>        111
>        111
>
> How can transform x in x'?
>
> Thanks in advance.

This seems to do it:

reshape(noise(1:27), 3, [])'

Subject: reshape a vector , split a vector

From: Jan Simon

Date: 11 Jun, 2010 21:44:04

Message: 3 of 4

Dear Jose!

> noise = 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 1
>
> round(length(noise)/3)=9
> x=reshape(noise(1:27),9,[])
> x =
>
> 1 1 0
> 1 1 0
> 1 1 0
> 1 0 1
> 0 0 1
> 0 0 1
> 0 1 1
> 1 1 1
> 1 1 1
>
> But the problem is that i am interested in this vector:
>
> x' =111
> 100
> 011
> 111
> 000
> 111
> 000
> 111
> 111

Do you search this:
  x = transpose(reshape(noise(1:27), 3, 9))
?

Jan

Subject: reshape a vector , split a vector

From: Jose

Date: 11 Jun, 2010 21:45:22

Message: 4 of 4

jrenfree <jrenfree@gmail.com> wrote in message <63904174-f79e-47b6-aa47-562755f21299@v12g2000prb.googlegroups.com>...
> On Jun 11, 2:09 pm, "Jose " <jose.l.v...@gmail.com> wrote:
> > Hello to everyone, i have got this vector and i want to split it in blocks 0f 3 elements:
> >
> > noise = 1     1     1     1     0     0     0     1     1     1     1     1     0     0     0     1     1     1     0     0     0     1     1     1     1     1     1     1
> >
> > round(length(noise)/3)=9
> >
> >  x=reshape(noise(1:27),9,[])
> >
> > x =
> >
> >      1     1     0
> >      1     1     0
> >      1     1     0
> >      1     0     1
> >      0     0     1
> >      0     0     1
> >      0     1     1
> >      1     1     1
> >      1     1     1
> >
> > But the problem is that i am interested in this vector:
> >
> > x' =111
> >       100
> >       011
> >       111
> >       000
> >        111
> >        000
> >        111
> >        111
> >
> > How can transform x in x'?
> >
> > Thanks in advance.
>
> This seems to do it:
>
> reshape(noise(1:27), 3, [])'


Thanks!!

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