Merging different arrays depending on condition
이전 댓글 표시
Hi
I have a following vector called cases as follows:
cases = [1,4,4,3,1,2,2,4,3,4,4,...];
Additionally, I have four arrays Array1 to Array4.
Now I want to construct a new Array, where the elements of this new array are picked from the Array1,...,Array4 depending on what the "cases" array indicates. So for instance, the first element of cases is "1" which means to pick from Array 1 (and I would like to do this in the right order, so I pick the first element of Array1). Then the second element of cases is a "4", so now I want to sample from Array 4, again the first element. The next element of cases is again "4", now I pick the second element of Array4 and so on. How can I do that effectively? The only thing which comes to my mind is to loop with ifelse loops, but that seems rather not so straightforward. Thanks
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!