フィルターのクリア

Import excel to matlab

1 回表示 (過去 30 日間)
Ryan Freeman
Ryan Freeman 2011 年 7 月 18 日
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?

回答 (1 件)

Chirag Gupta
Chirag Gupta 2011 年 7 月 18 日
[~, 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 件のコメント
Ryan Freeman
Ryan Freeman 2011 年 7 月 18 日
Thank you. I am getting an error at the line vername = genvarname ('data_' sheets {i}).
Chirag Gupta
Chirag Gupta 2011 年 7 月 19 日
My bad! it should be:
varname = genvarname( ['data_' sheets{i} ] );

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by