Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to sort a vector according to another vector
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a desired vector u of order 1x6 i.e. one row and 6 columns. Likewise I generate another random vector of same size 1x6. The arrangement of elements in that random vector is varying. Now I want to get such a random number which is nearly the same as my u vector. And also I want to re-arrange the elements of that random vector according to the arrangment of my u vector. How can I do that?
댓글 수: 1
답변 (1개)
Ameer Hamza
2020년 9월 30일
What about adding random values to the first vector
u = [2 1 3 6 4 2];
v = u + rand(size(u))*0.1;
Result
>> u
u =
2 1 3 6 4 2
>> v
v =
2.0032 1.0211 3.0612 6.0179 4.0297 2.0483
댓글 수: 1
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!