save cell array of strings and doubles to excel file
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, a simple question.
How to save a cell array to a *.xls file? my cell array consists of 2 arrays. one is array of strings and the other is double. using the following command does not work and error occurs. (I have attached my features_score file):
xlswrite('features.csv',cell2mat(features_score(:,1)),'A1'); %array of strings
xlswrite('features.csv',cell2mat(features_score(:,2)),'A2'); %array of double
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 83)
m{n} = cat(1,c{:,n});
Thank you in advance
0 commentaires
Réponse acceptée
Kirby Fears
le 15 Avr 2016
You can write cells directly to the file. If you're using xlswrite, you should specify a target file with an .xls or .xlsx extension.
Here's a simple way to do it with dummy data. You should be able to use it with your data the same way.
c1 = {'string';'data';'cell'};
c2 = {1;2;3};
xlswrite('features.xls',[c1,c2]);
Assuming c1 and c2 are Mx1 cell arrays, this will write M rows into columns A and B of the first sheet.
8 commentaires
Kirby Fears
le 15 Avr 2016
Modifié(e) : Kirby Fears
le 15 Avr 2016
A delimited text file such as *.csv. I've provided a solution with fprintf in your other thread:
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!