for loop for a specific cell of a list of arrays

1 回表示 (過去 30 日間)
Marcos Granados Flores
Marcos Granados Flores 2021 年 3 月 11 日
編集済み: Stephen23 2021 年 3 月 12 日
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 件のコメント
Jan
Jan 2021 年 3 月 11 日
編集済み: Jan 2021 年 3 月 11 日
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 2021 年 3 月 11 日
編集済み: Stephen23 2021 年 3 月 12 日
"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?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by