cell2txtfile(file,c​ell_array)

Version 1.1.0.0 (2,07 KB) von Li Chen
Write Cell Array to Text File
377 Downloads
Aktualisiert 22 Jan 2015

Lizenz anzeigen

function cell2txtfile(file,cell_array)
%%Written by Li CHEN on 22 Jan 2015, inspired by dlmcell %
%It is faster than dlmcell %
% <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> %%
% <><><><><> cell2txtfile - Write Cell Array to Text File <><><><><> %
% <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> %
% %
% 1. Input %
% - file The output filename (string). %
% - cell_array The cell array to be written. %
% %
% 2. Output %
% - filename.txt %
% 3. Example %
% cell2txt('filename.txt',cellarray); %
% %
% <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> %
%% Check input arguments
if nargin < 2
disp('Error - Give at least two input arguments!');
return;
elseif nargin > 2
disp('Error - Do not give more than 2 input arguments!');
return;
end
if ~ischar(file)
disp(['Error - File input has to be a string (e.g. ' ...
char(39) 'output.txt' char(39) '!']);
return;
end;
if ~iscell(cell_array)
disp('Error - Input cell_array not of the type "cell"!');
return;
end;
delimiter = '\t';
append = 'w';
%% Open output file
%tic
output_file = fopen(file,append);
[m,n]=size(cell_array);
%% Evaluate and write input array to the output file.
%disp('Writing the data to a txt file, wait a moment...')
for i=1:m
temp=strjoin(cell_array(i,:),delimiter);
fprintf(output_file,'%s\r\n',temp);
end
%% Close output file.
fclose(output_file);
%toc

Zitieren als

Li Chen (2024). cell2txtfile(file,cell_array) (https://www.mathworks.com/matlabcentral/fileexchange/49113-cell2txtfile-file-cell_array), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2014a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Tags Tags hinzufügen
Quellenangaben

Inspiriert von: dlmcell

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.1.0.0

data export

1.0.0.0