Cells to csv files
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have 1by3 cell as below.
'NSF4_TTD_55''NSF4_TTD_56''NSF4_TTD_57'
I want to write to csv file as such without hyphens like
column1 column2 column3 NSF4_TTD_55 NSF4_TTD_56 NSF4_TTD_57
Can anyone please help how can write them into csv file.
when i use csvwrite('filename.csv',filename);
it is splitting every letter (or character or symbol_ etc) into a separate column
please help how can I write in to csv file as 1-row and 3-column form
Thanks in advance,
0 Commenti
Risposte (1)
Geoff Hayes
il 8 Nov 2014
Mekala - according to the documentation at csvwrite, cell arrays are not accepted as inputs to the function. If you want to write cell data to file, please see export cell data to file where you will use fprintf. In your case, this would be something like
% data to write to file
cellArray = {'NSF4_TTD_55','NSF4_TTD_56','NSF4_TTD_57'};
% open the file for writing
fid = fopen('filename.csv','wt+');
if fid>0
% write each column to file
numCols = length(cellArray); % assumes that cellArray is row vector
for k=1:numCols
if k==numCols
fprintf(fid,'%s\n',cellArray{k});
else
fprintf(fid,'%s,',cellArray{k});
end
end
fclose(fid);
end
Try the above and see what happens!
0 Commenti
Vedere anche
Categorie
Scopri di più su Workspace Variables and MAT 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!