Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can i define sid_allyears = zeros(361,361,432); in my script

1 回表示 (過去 30 日間)
Sophia
Sophia 2016 年 3 月 29 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
% open binary file for
% Polar Pathfinder mean monthly 25 km EASE-Grid Sea Ice Motion Vectors, Version
folderpath = 'C:\Users\sk\Documents\MATLAB\nsidc0116_ice_motion_vector_v3\';
years = 1979:2014;
sid_allyears = zeros(361,361,432);
yearindex = 0;
for j = years;
disp(j);
yearindex = yearindex+1;
stryear = num2str(j);
filepath = fullfile(folderpath,stryear);
files = dir(fullfile(filepath,'\icemotion.grid.month.*.n.v3.bin') );
files = {files.name};
r_years = []; % (361,361,12)
d_years = []; % (361,361,12)
mm = 0 ;
for i=1:numel(files);
disp(files{i});
mm = mm+1;
filename = fullfile(filepath,files{i});
fid = fopen(filename);
rawdata = fread(fid,[361, inf],'int16');
fclose(fid);
% reshape it into a [3x361x361] matrix
tdata = reshape(rawdata,[3, 361, 361]);
% change 3d matrix to simple matrix, and divide by 10 to get cm/second
u = squeeze(tdata(1,:,:)./10.);
v = squeeze(tdata(2,:,:)./10.);
error = tdata(3,:,:)./10;
[TH,R] = cart2pol(v,u);
D = rad2deg(TH);
r_years(:,:,mm) = R;
d_years(:,:,mm) = D;
end
**sid_allyears = ?????**
end
  4 件のコメント
Walter Roberson
Walter Roberson 2016 年 3 月 29 日
sid_allyears(:,:,:,yearindex) = r_years;
Sophia
Sophia 2016 年 3 月 29 日
編集済み: Sophia 2016 年 3 月 29 日
Thanks Walter, it is working but the problem lies in the next part now. Since i have 432 files, ind values showing are 430-436, but since i don't have the complete winter data values for 2014(i just have oct to dec for 2014 not jan to apr 2015), so i want this ind to show 418-424 instead.
ind=10:16; % Winter average over month Oct to following year's April
for k=1:(ni/12)-1
meanr = nanmean(tr(i,j,ind));
tmeanr(i,j,k) = meanr;
ind = ind + 12;
end
The values in * *meanr* = nanmean(tr(i,j,ind));* are showing all zeros

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by