Hi, I have an array like A=[3;4 4; 6 6 ;5 5 5; 1 1 1 1]. I want to assign ascending numbers into this array as A(:,2)=[1; 2 2 ; 3 3 ; 4 4 4 ; 5 5 5 5] corresponding to each distinct numbers in A. Does anyone know how to do it? Thanks

댓글 수: 1

the cyclist
the cyclist 2017년 3월 5일
Your notation for specifying A is not valid syntax, so it is unclear what you mean.

댓글을 달려면 로그인하십시오.

 채택된 답변

the cyclist
the cyclist 2017년 3월 5일

1 개 추천

As I mentioned in my comment, it is not perfectly clear what you mean, but I think the unique command might do what you want. I redefined your definition of A, and used unique.
A = [3; 4; 4; 6; 6; 5; 5; 5; 1; 1; 1; 1]
[uA,i,j] = unique(A,'stable')
The value of j seems like what you want.

댓글 수: 1

Erdem Yenerdag
Erdem Yenerdag 2017년 3월 5일
Ohh, sorry for the wrong notation.. but your answer is exactly what I need. Thank you very much

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

질문:

2017년 3월 5일

댓글:

2017년 3월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by