Import excel to matlab
Mostra commenti meno recenti
I want to import data from excel into matlab. My data is separated into different sheets and I would like to save each sheet into its own variable (it is important that the sheets stay separated, I don't just want to import all the data into a single variable). Does anyone know how to do this?
Risposte (1)
Chirag Gupta
il 18 Lug 2011
[~, sheets, ~] = xlsfinfo('myfile.xls'); gives a cell array of sheets
for i = 1:length(sheets)
%create variable string
varname = genvarname('data_' sheets{i});
eval('varname = xlsread(''mytest.xls'',sheets{i})');
end
3 Commenti
Walter Roberson
il 18 Lug 2011
Note: if your MATLAB is not one of the newer ones, it may complain about unexpected operator at the ~ . If so then replace the two ~ with any unused variable names.
[junk, sheets, junk] = xlsinfo(....)
Ryan Freeman
il 18 Lug 2011
Chirag Gupta
il 19 Lug 2011
My bad! it should be:
varname = genvarname( ['data_' sheets{i} ] );
Categorie
Scopri di più su Data Import from MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!