Select Specific Values in Matrix Based on Index Values Listed in Array...

27 次查看(过去 30 天)
Good afternoon!
I had a question regarding filtering/selecting specific values within a matrix based on the values listed in an array. For example, I have an array ('b') with thousands of random numbers in ascending order representing the index value of data located in an nc file (i.e. array 'b' contains the numbers 1, 5, 7, 10, 25, 60, 89, and thousands more, and each of these represents the index value of a timestep in a separate nc file). The end goal is to use array 'b' to select the timesteps in my nc file for further use. Would I use the "ismember" function? Or "find"? Or should I use a for-loop instead? Any help would be greatly appreciated. (And I apologize in advance for my incessant questions...)
b = array with 12,000+ values representing index values in nc file

采纳的回答

Sindar
Sindar 2020-2-10
Actually, you can index directly with 'b' after loading your variable into 'a':
a(b,:)
It may be possible to only load the rows corresponding to b; if you want this, include your code that reads in the nc file

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by