for loop for a specific cell of a list of arrays

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
Jan
Jan il 11 Mar 2021
Modificato: Jan il 11 Mar 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 il 11 Mar 2021
Modificato: Stephen23 il 12 Mar 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?

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by