For Programmers: Free Programming Magazines  


Home > Archive > Matlab > June 2007 > Function to get only the different values of an array.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Function to get only the different values of an array.
Diego Gomes

2007-06-29, 7:14 pm

Hello,

I would like to know if there is a function that returns me only the
different values of an array. For example:

Imagine we have the following array:

a = (1 2 3 2 3 4 6 3 4)

I want to know if MatLab has a function that returns me the following
array:

result = (1 2 3 4 6)

The function is like the "SELECT DISTINCT" command of SQL.

Thanks.
us

2007-06-29, 7:14 pm

Diego Gomes:
<SNIP a matter of english...

> I would like to know if there is a function that returns me only

the different values of an array...

a hint:

help unique;

us
Diego Gomes

2007-06-29, 7:14 pm

I tried the MatLab help but I couldn't find. Do you know if exists?
us

2007-06-29, 7:14 pm

Diego Gomes:
<SNIP cannot fine <unique>(?)...

> Do you know if exists...


it's part of ML's basic toolbox

% try
which unique

us
Diego Gomes

2007-06-29, 7:14 pm

It worked, thank you very much.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com