Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
remove a numerical number from nx1 column vector

Subject: remove a numerical number from nx1 column vector

From: zheng

Date: 6 Jan, 2011 18:05:05

Message: 1 of 2

Thanks alot for anyone answering the question.

Here, I have a nx1 column vector output, I want to remove one value which is equal to -1 and save as a new (n-1)x1 column vector.

2
3
4
1
-1
5
8

what I want is
2
3
4
1
5
8

Subject: remove a numerical number from nx1 column vector

From: Sean de

Date: 6 Jan, 2011 19:17:05

Message: 2 of 2

"zheng " <fiendniu2003@hotmail.com> wrote in message <ig508h$bqo$1@fred.mathworks.com>...
> Thanks alot for anyone answering the question.
>
> Here, I have a nx1 column vector output, I want to remove one value which is equal to -1 and save as a new (n-1)x1 column vector.
>
> 2
> 3
> 4
> 1
> -1
> 5
> 8
>
> what I want is
> 2
> 3
> 4
> 1
> 5
> 8

x(5) = [];
or
x(x==-1) = [];
or
x2 = x(x~=-1);
or
x(find(x==-1,1,'first')) = [];
etc.

Tags for this Thread

No tags are associated with this thread.

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.

Contact us