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:
clear value in a vector

Subject: clear value in a vector

From: S?bastien Vilaseca

Date: 10 Mar, 2009 15:06:03

Message: 1 of 2

Hi,

I have the following vector: vector=[ 1 2 2 3 4 5 5 6] and I want to clear double values so that I have finally: vector=[1 2 3 4 5 6].

I tried with this loop, but it's not working:

for i=1:length(vector)
if vector(i)=vector(i-1)
clear('vector(i)')
end
end


Thanks for your help

Subject: clear value in a vector

From: John D'Errico

Date: 10 Mar, 2009 15:16:01

Message: 2 of 2

"S?bastien Vilaseca" <seb2000@bluewin.ch> wrote in message <gp5vkr$qec$1@fred.mathworks.com>...
> Hi,
>
> I have the following vector: vector=[ 1 2 2 3 4 5 5 6] and I want to clear double values so that I have finally: vector=[1 2 3 4 5 6].
>
> I tried with this loop, but it's not working:
>
> for i=1:length(vector)
> if vector(i)=vector(i-1)
> clear('vector(i)')
> end
> end

This will not work for so many reasons. Not the
least of those reasons is that clear does not delete
single elements from a vector.

help clear

Instead, why not use the tool that is designed
to solve your problem?

help unique

John

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