matlab - Save .mat file, use -v7.3 switch? -
i'm running m-file, creating 2 variables, clus
, watts_map
. want save both variables file ends in ".mat". both variables dimensioned (1152,241,319), 1152 360 deg longitude in 0.3125 deg increments, 241 latitude 30s-30n in 0.25 deg increments, on 319 time steps. code works way until end, error:
[warning: variable 'clus' cannot saved mat-file version older 7.3. save variable, use -v7.3 switch. skipping...] [warning: variable 'watts_map' cannot saved mat-file version older 7.3. save variable, use -v7.3 switch. skipping...]
i using matlab version r2014a, think current version. also, have run same exact code on smaller spatial domain (but on 2920 timesteps) without error.
% clear variables, initialize counter, indexed timestep clc; clear all; rain = nan(1152,241,319); clus = nan(1152,241,319); areas_final = nan(500,319); wattage_final = nan(500,319); cluster_size = zeros(319,1); watts_map = zeros(1152,241,319); year = 2000%:2008; nyear = sprintf('%04d',year); % call on files each year filename = (['pr_3hr_gfdl-hiram-c360_amip_r1i1p1_' num2str(nyear) '010100-' num2str(nyear) '123123_subset_tropics.nc']); disp(filename) disp(year) rain_rate = ncread(filename,'pr'); % call on each timestep = 960:4:2236; % approx may 1st-sep 30th % set extract subset region, mask land areas, each % timestep disp(i) rain = rain_rate(:,:,i); % eliminate bad/no data points index_rain = (rain >= (5.4e-05)) & (rain < 1e-2); % 0.2mm/hr min rain rate % cluster each morning , afternoon matrix clus(:,:,i) = cluster_it(index_rain); % calculate cluster areas areas = cluster_areas_tropics(clus(:,:,i)); areas_final(1:length(areas),i) = areas; % calculate cluster wattages wattage = cluster_wattage(clus(:,:,i),rain); cluster_size(i,1) = max(max(clus(:,:,i))); % create dummy matricies populate , use create wattage % maps d = zeros(1152,241); e = squeeze(clus(:,:,i)); index = 1:cluster_size(i); d(e == index) = wattage(index); end watts_map(:,:,i) = d; % clear dummy matricies clear d e end % save output .mat file file_out = sprintf(num2str(nyear), year); matfile = [file_out '_tropics_watts_maps_inc_land_low_rain_threshold.mat']; save(matfile, 'clus', 'watts_map'); % clear unneeded variables save memory , prevent overwriting clear index_rain rain areas wattage clus file_out filename areas_final rain_rate watts_map cluster_size year matfile end
even in current version, default format not v7.3. must specify it:
save(matfile, '-v7.3', 'var1', 'var2');
you can set default in "general preferences":
note v7.3 compress data of r2008a:
compression of -v7.3 mat-files
can store data items on 2 gigabytes in size in mat-file using -v7.3 option save function. option introduced in matlab r2006b. matlab r2008a, save compresses these mat-files.
i've seen file size blow v7.3 files, history , perhaps it's better now.
Comments
Post a Comment