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

조회 수: 17 (최근 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