writing cellArray to txt file.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sermet
am 8 Mär. 2014
Beantwortet: Azzi Abdelmalek
am 8 Mär. 2014
%for example;
cellArray=
'p1' [400] [500] [600]
'p2' [650.45] [400.78] [390.90]
[ 3] [400.02] [500.05] [600.120]
%I need to write this cellArray into .txt file as it seems above (3x3). This dimensions would change due to the computations therefore I need to perform loop for writing into txt. Which codes I need to perform orderly place columns and rows of this cellArray into txt file?
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 8 Mär. 2014
cellArray={'p1' [400] [500] [600]
'p2' [650.45] [400.78] [390.90]
[ 3] [400.02] [500.05] [600.120]}
c=cellfun(@num2str,cellArray,'un',0)
[n,m]=size(c)
filename = 'file.txt';
form=[repmat('%s ',1,m) ' \r\n']
fid = fopen(filename, 'w');
for k=1:n
fprintf(fid, form, c{k,:});
end
fclose(fid);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Text Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!