How to copy elements of a matrix in an array Uniquely?

Hello I am a student n i want to write a program which takes input as a matrix of any dimension and returns an array of its elements but they should be unique. element's appearance should be once only. I have written a small code but it is showing req output. The code is:
mat=rand(1,6) copy1(1)=mat(1) for i=2:length(mat) for j=1:length(copy1) if (mat(i)~=copy1(j)) copy1(i)=mat(i); else break; end
end
end
Kindly help....
@sh

 채택된 답변

추가 답변 (1개)

Ash
Ash 2012년 2월 10일

0 개 추천

hi thanks alot for ur help. unique function has worked. Can u please help me to find probability of elements in a matrix... for example: if input is:
A=[1 2;1 3;4 5; 2 5]
then output req is:
prob=[1 0.25; 2 0.25; 3 0.125; 4 0.125; 5 0.25]
Kindly help...

카테고리

도움말 센터File Exchange에서 Specialized Power Systems에 대해 자세히 알아보기

태그

질문:

Ash
2012년 2월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by