xlswrite many data arrays into excel
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Please help, i am new to matlab GUI coding. I have many dataarray such as
set1={'year' 'date' 'day' 'time'; '2017' '0803' 'Monday' '15.15'; '2015' '0303' 'Tuesday' '08.20'}
set2={'year' 'date' 'day' 'time'; '2016' '0705' 'Friday' '17.15'; '2013' '0310' 'Monday' '18.20'}
title={'dataset1' 'dataset2'}
The data arrays that I have is much longer (400-1000 rows) and I have about 20 different set, but the number changes dependent on the GUI data. What I want to do is automatically export this all these arrays into a single excel spreadsheet with each set as separate sheets with the sheet-title specified in the "title" string.
So far I am using
[FileNameBodeWrite, PathNameBodeWrite] = uiputfile({'*.xls'},'Save As...',
[Title{1,1} '.xls']);
([PathNameBodeWrite FileNameBodeWrite ],[Set1],1,'A1')
But that of cause only works for that specific set. I want to include them all in one spreadsheet, potentially in a loop???
0 commentaires
Réponse acceptée
Jan
le 24 Août 2017
Modifié(e) : Jan
le 24 Août 2017
You find many threads concerning this problem in the forum. See https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval. The problem is the hidden number in the name of the variable. If you use an array instead, the solution is easy:
Data = {set1, set2}; % Better use a cell array from the beginning
Title = {'dataset1' 'dataset2'};
File = fullfile(PathNameBodeWrite, FileNameBodeWrite);
for k = 1:numel(Data)
xlswrite(File, Data{k}, Title{k}, 'A1');
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!