Stop overwriting output variables
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
David du Preez
am 2 Apr. 2017
Beantwortet: Star Strider
am 2 Apr. 2017
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.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 2 Apr. 2017
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Point Cloud Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!