Prev: imwrite error
Next: fread and endian issues
From: mee gestaf on 16 Jun 2010 10:10 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.
From: utab on 16 Jun 2010 10:12 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
From: mee gestaf on 16 Jun 2010 10:26 utab <utabak(a)tudelft.nl> wrote in message <b1015$4c18dbb4$82a112b1$11192(a)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:
From: dpb on 16 Jun 2010 10:26 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... --
From: Matt Fig on 16 Jun 2010 10:30
setdiff(v,u) |