# alternative from two vectors matlab

To find an alternative from two vectors in MATLAB, you can use the `setdiff`

function. This function returns the values from the first input vector that are not present in the second input vector. Here's an example:

```
vector1 = [1, 2, 3, 4, 5];
vector2 = [3, 4, 5, 6, 7];
result = setdiff(vector1, vector2);
```

In this example, the `result`

variable will contain the values `[1, 2]`

, which are the elements in `vector1`

that are not present in `vector2`

.

Please note that the order of the input vectors matters. If you want to find the elements that are unique to each vector, you can use the `union`

function instead:

```
vector1 = [1, 2, 3, 4, 5];
vector2 = [3, 4, 5, 6, 7];
result = union(setdiff(vector1, vector2), setdiff(vector2, vector1));
```

In this case, the `result`

variable will contain the values `[1, 2, 6, 7]`

, which are the elements that are unique to either `vector1`

or `vector2`

.

I hope this helps!