for loop for a specific cell of a list of arrays

1 visualización (últimos 30 días)
Marcos Granados Flores
Marcos Granados Flores el 11 de Mzo. de 2021
Editada: Stephen23 el 12 de Mzo. de 2021
Hi, everyone.
I have a list of arrays from sst1 to sst365. Every of those arrays have dimensions 142x116.
I want to use a for loop for extract the cell (49,90) from every array of the list and get a resultant array with dimensions 365x1 called 'sst'.
Anyone have idea how can I get that? I was trying the following loop but I didn't get it.
Thank you so much
loni = -87.125; lati=22.125; %the long and lat values I want from each array
ix = find(lon==loni) % to find the row to corresponds the lon value in each array = 49
iy = find(lat==lati) % to find the column to corresponds the lat value in each array = 90
for ti=1:length(fecha)
sst(ti) = sst(ix,iy)
end
  6 comentarios
Jan
Jan el 11 de Mzo. de 2021
Editada: Jan el 11 de Mzo. de 2021
I have 365 arrays called sst1, sst2, sst3, sst4, ... , sst365
Then this is the main problem. Do not create a bunch of variables, but use an array and indexing. If the variables have different sizes, a cell array is working. See https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval
Stephen23
Stephen23 el 11 de Mzo. de 2021
Editada: Stephen23 el 12 de Mzo. de 2021
"I have 365 arrays called sst1, sst2, sst3, sst4, ... , sst365"
How did you get them all into the workspace? Did you name them all by hand?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by