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
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!