Convert matrices to .csv from a double matrix and header cell
이전 댓글 표시
Hi
I would like to put headers into a csv file i've converted. So I have a (59, 26896) double matrix which i converted to csv. However I also have a cell matrix (1,26896) header file that i would like to include. This is what I've tried:
csvwrite('result.csv', result);
commaHeader = [header;repmat({','},1,numel(header))]; %insert commaas
commaHeader = commaHeader(:)';
textHeader = cell2mat(commaHeader); %cHeader in text with commas
%write header to file
fid = fopen('result.csv','w');
fprintf(fid,'%s\n',textHeader)
fclose(fid)
%write data to end of file
dlmwrite('result.csv',result,'-append');
I gives me a totally wrong output of (59, 60353) instead of a (60, 26896) i would expect. Any help would be greatly appreciated. Thank you.
Kevin
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!