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

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
vector manipula... Diego Lass 24 Jun, 2009 18:39:02
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com