Error using .* in MATLAB

2 Ansichten (letzte 30 Tage)
Sophia
Sophia am 24 Sep. 2014
Bearbeitet: dpb am 24 Sep. 2014
% path to data directory on Jens' iMac
folderpath = '/C:/SIC_data/daily/';
%%latitudes and longitudes and area elements for each grid cell
fid = fopen('psn25lats_v3.dat');
lat = fread(fid,[304,448],'int')./100000;
fclose(fid);
fid = fopen('psn25lons_v3.dat');
lon = fread(fid,[304,448],'int')./100000;
fclose(fid);
fid = fopen('psn25area_v3.dat');
area = fread(fid,[304,448],'int')./1000;
fclose(fid);
%%process years 2002-2012
years = 2002:2012;
% initiate ice concentration tensor
ice_conc_daily = NaN.* zeros(304,448,numel(years),366); % (rows, columns, years, days)
for year = years,
disp(year); % show year on screen to follow progress
% a year index
yi = year - min(years) + 1;
% each year in separate folder named 'year'
datapath = fullfile( num2str(year), '/');
% make list of files in selected folder
files = dir( fullfile(folderpath,datapath,'nt_*_v01_n.bin') );
% exception!
if year==2007, % we have two satellites this year and twice the files, only use f17
files = dir( fullfile(folderpath,datapath,'nt_*_f17_v01_n.bin') ); % only f17 sensor
end
files = {files.name}';
% go through all files and add into datamatrix dcube
for i=1:numel(files)
%disp(files{i}); % show filename on screen to follow progress
filename = fullfile(folderpath,datapath,files{i}); % full path to file
fid = fopen(filename);
d = fread(fid,[304,448]); % read data, call it 'd'
fclose(fid);
% % Table 5. Description of Data Values
% % Data Value Description
% % 0 - 250 Sea ice concentration (fractional coverage scaled by 250)
% % 251 Circular mask used in the Arctic to cover the irregularly-shaped data gap around the pole (caused by the orbit inclination and instrument swath)
% % 252 Unused
% % 253 Coastlines
% % 254 Superimposed land mask
% % 255 Missing data
% calculate percentage sea ice concentration
d(d<=250) = d(d<=250)./250 .* 100; % keep values over 250
%d(d>250)=NaN; % remove values over 250
% extract date from filename
dstring = files{i};
yyyy = str2double(dstring(4:7)); % had to change to double because of datenum
month= str2double(dstring(8:9));
day = str2double(dstring(10:11));
doy = datenum(yyyy,month,day)-datenum(yyyy,1,0); % day of year
% create large tensor
ice_conc_daily(:,:, yi, doy) = d;
end
end
%
% % save to file
% save NSIDC_NT_25km_2002_2012_daily_ice_conc.mat ice_conc_daily lat lon area -v7.3
  1 Kommentar
Matt J
Matt J am 24 Sep. 2014
You need to ask a question. If it's about an error, you need to copy/paste the error messages.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by