Replace values in an array with values from a single row in another array
1 view (last 30 days)
Show older comments
I have two arrays, A of size 96*183106 and B of size 1298*121. Array B is filled with indices of data from array A that I'm interest in. I want to replace all the values in array B with data from the first row only of array A. In other words, each value in B is a specific index of the first row of array A that I want to extract. Given the difference in dimensions I'm guessing I'll have to transform one these arrays but I'm at loss on how to reach my end goal. If anyone could give me some pointers in the right direction I would appreciated it.
0 Comments
Accepted Answer
Guillaume
on 6 Sep 2017
A(sub2ind(size(A), repmat(1, size(B)), B)) %the 1 stands for row 1.
is all that is needed.
This will give you the values in an array the same size as B. You can reshape that in any form you want.
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!