what I can make the average of the next nc files?

조회 수: 2 (최근 30일)
E Rodriguez
E Rodriguez 2011년 9월 1일
I have to read some nc files and I'm creating a list as show here:
list_names= cellstr([
'filename_1'
'filename_2'
'filename_3']);
for i= 1:length(list_names)
readfile = char(list_names(i));
getinfo = hdfinfo(readfile);
% Read the files
ncid(i) = netcdf.open(readfile,'NC_WRITE');
IDaod= netcdf.inqVarID(ncid(i),'DATA');
% DATA=squeeze(DATA);
DATAt = zeros(150,162);
DATA= netcdf.getVar(ncid(i), IDDATA);
netcdf.close(ncid);
I have to do the average of the files I'm reading how I can do that?
  댓글 수: 3
Oleg Komarov
Oleg Komarov 2011년 9월 1일
Interactive tutorial on how to format: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup#answer_18099
E Rodriguez
E Rodriguez 2011년 9월 1일
I did what you suggest all ready but the code doesn't change.

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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 9월 1일
The function is mean().
  댓글 수: 2
E Rodriguez
E Rodriguez 2011년 9월 1일
Thank you for your answer I tried mean already but it looks like the code is not reading the all files, because is give only one raw as result.
Fangjun Jiang
Fangjun Jiang 2011년 9월 1일
Okay, then you need to accumulate them together, something like.
Total=zeros(5,5);
N_file=3;
for k=1:N_file
Total=Total+k*rand(5,5); %just use k*rand(5,5) here as an example
end
Average=Total/N_file;
MeanValue=mean(Average);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by