Show certain value in Cell array

3 ビュー (過去 30 日間)
David du Preez
David du Preez 2017 年 4 月 4 日
コメント済み: David du Preez 2017 年 4 月 4 日
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.

採用された回答

Image Analyst
Image Analyst 2017 年 4 月 4 日
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 件のコメント
David du Preez
David du Preez 2017 年 4 月 4 日
Sorry. I should I have said that it is for the data1 variable.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by