COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### 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

```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

```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

```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

```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

```setdiff(v,u)
```
 0

```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

```> doc setdiff  % (diff() is 1st-order differences within vector)
>
> and friends...
>
> --
thank you, that is what I need it.
```
 0

7 Replies
278 Views

Similiar Articles:

7/29/2012 10:46:51 PM