Get the values of an array from indices in another array: Matlab

前端 未结 2 1405
情话喂你
情话喂你 2021-01-26 10:22

I have a 20x1 double array A, and a 1000x1 double array B.

I want to get array C, where array C will be 1000x1 doubl

2条回答
  •  心在旅途
    2021-01-26 10:49

    I did it using for loop as shown below, not sure if this is the ideal solution:

    C = zeros(1000,1);
    
    for i = 1:1000
        C(i,1) = A(B(i));
    end 
    

提交回复
热议问题