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

New to MATLAB?

removing equal elements from a matrix

Asked by som

som (view profile)

on 26 Feb 2013

Hi all,

I have a matrix like "a" whose some elemnts are equal to each other. I wato to transform this matrix to a vector like "b" with non-equal elements.

e.g. a=[ 1 2 3 ; 3  4 5; 6 4 7];  >> b=[1 2 3 4 5 6 7];

How can I write this program? Thanks in advance.

0 Comments

som

som (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 26 Feb 2013
Edited by Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 26 Feb 2013
Accepted answer
a=[ 1 2 3 ; 3  4 5; 6 4 7]; 
b=unique(a(:))'

2 Comments

Andrei Bobrov

Andrei Bobrov (view profile)

on 26 Feb 2013
unique(a)
som

som (view profile)

on 26 Feb 2013

Thanks a lot

Azzi Abdelmalek

Azzi Abdelmalek (view profile)

Contact us