Commit d1f1d1be authored by Jean-Yves TINEVEZ's avatar Jean-Yves TINEVEZ
Browse files

Method to export results to csv or xslx.

parent 4430811e
......@@ -23,6 +23,9 @@ classdef deproj
% Export masurements to a table.
T = to_table( obj )
% Exports results to a spreadsheet file.
to_file( obj, file_name, include_header )
%% Generate figures.
% Figure with the local plan orientation for a collection of epicells.
......
function to_file( obj, file_name, include_header )
%TO_FILE Exports results to a spreadsheet file.
% We include the variable units in the header.
if nargin < 3
include_header = true;
end
T = obj.to_table;
if ~include_header
writetable( T, file_name, 'WriteVariableNames', false );
return
end
% Add a first line with units.
[ n_rows, n_cols ] = size( T );
header = cell( 1, n_cols );
T2 = cell2table( cell( n_rows + 1, n_cols ) );
for c = 1 : n_cols
units = T.Properties.VariableUnits{ c };
var_name = T.Properties.VariableNames{ c };
if isempty( units )
head = var_name;
else
head = sprintf( '%s_(%s)', var_name, units );
end
header{ 1, c } = head;
end
T2{ 1, : } = header;
T2{ 2 : end , : } = table2cell( T( : , : ) );
writetable( T2, file_name, 'WriteVariableNames', false );
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment