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:
Insert elements into the vector

Subject: Insert elements into the vector

From: Diego Lass

Date: 24 Jun, 2009 22:37:01

Message: 1 of 4

Hi
I would like to insert values into a vector with the location of insertion known, how do I insert them.
For example,
A = [2 ; 2; 3; 4]
A = 2
      2
      3
      4
       
I want to insert 0 every 1 element(variable, can change) i.e
B = 2
      0
      2
      0
      3
      0
      4
      0

Thanks
Diego

Subject: Insert elements into the vector

From: Nathan

Date: 24 Jun, 2009 22:48:44

Message: 2 of 4

On Jun 24, 3:37 pm, "Diego Lass" <dlISC...@gmail.com> wrote:
> Hi
> I would like to insert values into a vector with the location of insertion known, how do I insert them.
> For example,
> A = [2 ; 2; 3; 4]
> A = 2
>       2
>       3
>       4  
>
> I want to insert 0 every 1 element(variable, can change) i.e
> B = 2
>       0
>       2
>       0
>       3
>       0
>       4
>       0
>
> Thanks
> Diego

This is the third discussion regarding the same vague topic you have
made in a row. Why not come out and ask the whole question so people
can answer it to your specifications?
Thanks
-Nathan

Subject: Insert elements into the vector

From: Diego Lass

Date: 24 Jun, 2009 22:57:01

Message: 3 of 4

OK, so the question is
I want to do ttest2 with two sets of vectors, but I don't want to test every single pair (testing is expansive). I only need to test certain pair. I know how to select the pair know. However, I want the whole list of the pairs. not just the ones I test. ttest2 will only give the pairs I tested, so I have to insert 0 for the pairs I didn't test. How do I insert the zeros?
Thanks
Diego

Nathan <ngreco32@gmail.com> wrote in message <640c3b3b-cdf8-40be-bf4f-c6d4491af598@i4g2000prm.googlegroups.com>...
> On Jun 24, 3:37?pm, "Diego Lass" <dlISC...@gmail.com> wrote:
> > Hi
> > I would like to insert values into a vector with the location of insertion known, how do I insert them.
> > For example,
> > A = [2 ; 2; 3; 4]
> > A = 2
> > ? ? ? 2
> > ? ? ? 3
> > ? ? ? 4 ?
> >
> > I want to insert 0 every 1 element(variable, can change) i.e
> > B = 2
> > ? ? ? 0
> > ? ? ? 2
> > ? ? ? 0
> > ? ? ? 3
> > ? ? ? 0
> > ? ? ? 4
> > ? ? ? 0
> >
> > Thanks
> > Diego
>
> This is the third discussion regarding the same vague topic you have
> made in a row. Why not come out and ask the whole question so people
> can answer it to your specifications?
> Thanks
> -Nathan

Subject: Insert elements into the vector

From: Nathan

Date: 24 Jun, 2009 23:03:56

Message: 4 of 4

On Jun 24, 3:57 pm, "Diego Lass" <dlISC...@gmail.com> wrote:
> OK, so the question is
> I want to do ttest2 with two sets of vectors, but I don't want to test every single pair (testing is expansive). I only need to test certain pair.  I know how to select the pair know.  However, I want the whole list of the pairs. not just the ones I test.  ttest2 will only give the pairs I tested, so I have to insert 0 for the pairs I didn't test.  How do I insert the zeros?
> Thanks
> Diego  
>
> Nathan <ngrec...@gmail.com> wrote in message <640c3b3b-cdf8-40be-bf4f-c6d4491af...@i4g2000prm.googlegroups.com>...
> > On Jun 24, 3:37?pm, "Diego Lass" <dlISC...@gmail.com> wrote:
> > > Hi
> > > I would like to insert values into a vector with the location of insertion known, how do I insert them.
> > > For example,
> > > A = [2 ; 2; 3; 4]
> > > A = 2
> > > ? ? ? 2
> > > ? ? ? 3
> > > ? ? ? 4 ?
>
> > > I want to insert 0 every 1 element(variable, can change) i.e
> > > B = 2
> > > ? ? ? 0
> > > ? ? ? 2
> > > ? ? ? 0
> > > ? ? ? 3
> > > ? ? ? 0
> > > ? ? ? 4
> > > ? ? ? 0
>
> > > Thanks
> > > Diego
>
> > This is the third discussion regarding the same vague topic you have
> > made in a row. Why not come out and ask the whole question so people
> > can answer it to your specifications?
> > Thanks
> > -Nathan

Well, do a repmat, set to zeros, then reshape?
A = [2;2;3;4];
A = repmat(A',2,1);
A(2,:) = 0;
B = reshape(A,1,[]);

Something like this?

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