Borrar filtros
Borrar filtros

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

20 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Sindar
Sindar el 10 de Feb. de 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

Más respuestas (0)

Categorías

Más información sobre Cell Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by