Hi all,
I am trying to read the variables from the list of characters those are saved as .mat file 'attached screenshot.' each of those .mat file has sst, lat, lon. I could not find a proper way to get the data by using the for loop.
for N = 1:nfiles;
filename = [flist(N).name];
disp(['Processing ', flist(N).name]);
end
Any help will be appreciated :(
thanks

댓글 수: 1

Stephen23
Stephen23 2018년 12월 18일
Note that square brackets are a concatenation operator in MATLAB, so they are completely redundent on this line (you are not concatenating anything):
filename = [flist(N).name];

댓글을 달려면 로그인하십시오.

 채택된 답변

Stephen23
Stephen23 2018년 12월 18일
편집: Stephen23 2018년 12월 18일

0 개 추천

D = 'path of the directory where those files are saved';
S = dir(fullfile(D,'erdMH*.mat'));
for k = 1:numel(S)
T = load(fullfile(D,S(k).name));
S(k).lat = T.lat;
S(k).lon = T.lon;
S(k).sst = T.sst;
end
If the imported data have compatible sizes you could concatenate them into arrays, e.g.:
lat = [S.lat]
lon = [S.lon]

댓글 수: 4

Lilya
Lilya 2018년 12월 19일
Thank you so so so much!! :')
Lilya
Lilya 2018년 12월 19일
i just have one question, I want the final sst matrix separated. as i get it as an accumulative meaning:
1*458*289 insted of 1*23385*289
Thanks in advance
Stephen23
Stephen23 2018년 12월 19일
편집: Stephen23 2018년 12월 19일
"I want the final sst matrix separated"
I do not know what a "separated" matrix is. You can access the imported sst arrays:
  • directly from the non-scalar structure S, or
  • concatenating together (as I showed in my answer), or
  • by putting them into a cell array:
C = {S.sst}
Lilya
Lilya 2018년 12월 19일
Thanks a lot !!! it works

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

질문:

2018년 12월 18일

댓글:

2018년 12월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by