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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by