Question Regarding Sorting of the elements
조회 수: 11 (최근 30일)
이전 댓글 표시
say I have vector [ 4 2 6] representing indicies and each of them has values V1= [ 5 9 1]
and I have another vector [ 1 5 3 ] again representing indicies and each of them has the corresponding values v2= [ 0 0 0 ]
What I want is to rearrange the CORRESPONDING values of the indicies combined( in ascending order of the indicies) which would get me a vector as follows :
X = [ 0 9 0 5 0 1]
How can i get vector X ?
댓글 수: 0
답변 (1개)
Stephen23
2018년 12월 13일
>> X1 = [ 4 2 6];
>> V1 = [ 5 9 1];
>> X2 = [ 1 5 3];
>> V2 = [ 0 0 0];
>> X(X1) = V1;
>> X(X2) = V2
X =
0 9 0 5 0 1
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!