Map an array yo another one
조회 수: 2 (최근 30일)
이전 댓글 표시
I have an array like: A=[3,5,6,10] and I need to map it to another one like: B=[1,2,3,4] so instead of returning A, I can return B. how can I do this?
댓글 수: 2
Guillaume
2018년 2월 15일
The question is really not clear. What does map mean? How do you go from [3 5 6 10] to [1 2 3 4]? What is the rule?
답변 (2개)
Andrei Bobrov
2018년 2월 15일
편집: Andrei Bobrov
2018년 2월 15일
A=[3,5,6,10];
B=[1,2,3,4];
C = randsrc(8,5,B);
ii = discretize(C,B);
out = A(ii);
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!