writing cellArray to txt file.
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
sermet
il 8 Mar 2014
Risposto: Azzi Abdelmalek
il 8 Mar 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 Commenti
Risposta accettata
Azzi Abdelmalek
il 8 Mar 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Text Files in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!