Create a vector out of other two vectors

  • Follow


I'm new in Matlab and I'm trying to create a new vector out of  the elements of another vector with the condition that the elements should not be contained by another vector. To be more clear I'll give an example:
I have 2 vectors v=[1,2,3,4,5,6] and w=[3,4] . I want to create a vector u, w made by the elements of v and without the elements of w; ex u=[1,2,5,6].
I looked for a function but I couldn't find it. Please can someone tell me how to do this.
0
Reply mee 6/16/2010 2:10:08 PM

On Wed, 16 Jun 2010 14:10:08 +0000, mee gestaf wrote:


> example: I have 2 vectors v=[1,2,3,4,5,6] and w=[3,4] . I want to create
> a vector u, w made by the elements of v and without the elements of w;
> ex u=[1,2,5,6]. I looked for a function but I couldn't find it. Please
> can someone tell me how to do this.
 
see help diff
0
Reply utab 6/16/2010 2:12:04 PM


utab <utabak@tudelft.nl> wrote in message <b1015$4c18dbb4$82a112b1$11192@news1.tudelft.nl>...
> On Wed, 16 Jun 2010 14:10:08 +0000, mee gestaf wrote:
> 
> 
> > example: I have 2 vectors v=[1,2,3,4,5,6] and w=[3,4] . I want to create
> > a vector u, w made by the elements of v and without the elements of w;
> > ex u=[1,2,5,6]. I looked for a function but I couldn't find it. Please
> > can someone tell me how to do this.
>  
> see help diff

10x for the riply, but I can't see how this could help me. It says that  for
Y = diff(X) calculates differences between adjacent elements of X.
If X is a vector, then diff(X) returns a vector, one element shorter than X, of differences between adjacent elements:
0
Reply mee 6/16/2010 2:26:05 PM

utab <utabak@tudelft.nl> wrote in message <b1015$4c18dbb4$82a112b1$11192@news1.tudelft.nl>...
> On Wed, 16 Jun 2010 14:10:08 +0000, mee gestaf wrote:
> 
> 
> > example: I have 2 vectors v=[1,2,3,4,5,6] and w=[3,4] . I want to create
> > a vector u, w made by the elements of v and without the elements of w;
> > ex u=[1,2,5,6]. I looked for a function but I couldn't find it. Please
> > can someone tell me how to do this.
>  
> see help diff

10x for the riply, but I can't see how this could help me. It says that  for
Y = diff(X) calculates differences between adjacent elements of X.
If X is a vector, then diff(X) returns a vector, one element shorter than X, of differences between adjacent elements:
0
Reply mee 6/16/2010 2:26:05 PM

utab wrote:
> On Wed, 16 Jun 2010 14:10:08 +0000, mee gestaf wrote:
> 
> 
>> example: I have 2 vectors v=[1,2,3,4,5,6] and w=[3,4] . I want to create
>> a vector u, w made by the elements of v and without the elements of w;
>> ex u=[1,2,5,6]. I looked for a function but I couldn't find it. Please
>> can someone tell me how to do this.
>  
> see help diff

that would be

doc setdiff  % (diff() is 1st-order differences within vector)

and friends...

--
0
Reply dpb 6/16/2010 2:26:57 PM

setdiff(v,u)
0
Reply Matt 6/16/2010 2:30:26 PM

On Wed, 16 Jun 2010 09:26:57 -0500, dpb wrote:


> 
> doc setdiff  % (diff() is 1st-order differences within vector)

of course, my humble apologies :)

0
Reply utab 6/16/2010 2:35:01 PM

> doc setdiff  % (diff() is 1st-order differences within vector)
> 
> and friends...
> 
> --
thank you, that is what I need it.
0
Reply mee 6/16/2010 2:42:04 PM

7 Replies
278 Views

(page loaded in 0.049 seconds)

Similiar Articles:













7/29/2012 10:46:51 PM


Reply: