Convert matrices to .csv from a double matrix and header cell
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Text Data Preparation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!