Show certain value in Cell array

3 Ansichten (letzte 30 Tage)
David du Preez
David du Preez am 4 Apr. 2017
Kommentiert: David du Preez am 4 Apr. 2017
Hi. I have the following code which only opens and reads files depending on the file size then the variable output for each file is done in same cell array;
files = dir('D:\MLS_2\2008\v03');
% Loop for each file
for i = 1:length(files)
if files(i).bytes > 50000
filename = files(i).name;
% display names that are read
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-GEOS5/Data Fields/L2gpValue';
data_id = H5D.open(file_data,DATAFIELD_NAME);
% Time component
TIME_NAME='HDFEOS/SWATHS/O3 column-GEOS5/Geolocation Fields/Time';
time_id = H5D.open(file_data,TIME_NAME);
% Variables wanted
data1{i} =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{i} =datestr(datevec(datenum(1993,1,1,0,0,0)+time(1)/86400));
end
end
Some of the variable output looks like this[228.069580078125;226.937240600586;228.856262207031]. How do I only display the left most value in the cell array.

Akzeptierte Antwort

Image Analyst
Image Analyst am 4 Apr. 2017
I'm not sure which variable you're talking about, but if [228.069580078125;226.937240600586;228.856262207031] is the contents of some particular cell you're looking at, let's call it thisCell, then to print it out to the command window you'd do
thisCell = ..... whatever ......
thisCellContents = cell2mat(thisCell); % Convert contents into column vector of N doubles.
fprintf('The first number = %f\n', thisCellContents(1));
  1 Kommentar
David du Preez
David du Preez am 4 Apr. 2017
Sorry. I should I have said that it is for the data1 variable.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Workspace Variables and MAT Files finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by