Stop overwriting output variables

1 次查看(过去 30 天)
Hi. I have the following code which only opens and reads files depending on the file size.
% File directory
files = dir('D:\MLS_2\2006\v04')
% Loop for each file
for i = 1:length(files)
if files(i).bytes > 50000
filename = files(i).name;
disp(filename)
%open files with data
file_data = H5F.open(filename,'H5F_ACC_RDONLY','H5P_DEFAULT');
%Data field for data wanted
DATAFIELD_NAME = 'HDFEOS/SWATHS/O3 column/Data Fields/L2gpValue';
data_id = H5D.open(file_data,DATAFIELD_NAME);
%Time component
TIME_NAME='HDFEOS/SWATHS/O3 column/Geolocation Fields/Time';
time_id = H5D.open(file_data,TIME_NAME);
%Variables wanted
data1=H5D.read (data_id,'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL', ...
'H5P_DEFAULT');
time=H5D.read(time_id,'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL',...
'H5P_DEFAULT');
time1lvl=datestr(datevec(datenum(1993,1,1,0,0,0)+time(1)/86400));
end
end
How can I stop the output variables (data1, time and time1lvl) that I want from being over-written each time. I also want to combine data1 and time1lvl.

采纳的回答

Star Strider
Star Strider 2017-4-2
I would save them as cell arrays:
Example:
data1{i} = H5D.read (data_id,'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL', ...
'H5P_DEFAULT');
time{i} = H5D.read(time_id,'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL',...
'H5P_DEFAULT');
time1lvl{i} = datestr(datevec(datenum(1993,1,1,0,0,0)+time(1)/86400));
Note the curly brackets ‘{}’ denoting cell array indexing.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Point Cloud Processing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by