필터 지우기
필터 지우기

Stop overwriting output variables

조회 수: 2 (최근 30일)
David du Preez
David du Preez 2017년 4월 2일
답변: Star Strider 2017년 4월 2일
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