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,

답변 (1개)

Geoff Hayes
Geoff Hayes 2014년 11월 8일

1 개 추천

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!

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

질문:

2014년 11월 8일

답변:

2014년 11월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by