Select Specific Values in Matrix Based on Index Values Listed in Array...
27 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Michelle De Luna
am 10 Feb. 2020
Beantwortet: Sindar
am 10 Feb. 2020
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 Kommentare
Akzeptierte Antwort
Sindar
am 10 Feb. 2020
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!