I have few excel program that I needed to be read by MATLAB. Now I want to enter the file name as an input. How do I make Matlab read that input file name?
2 ビュー (過去 30 日間)
古いコメントを表示
SOHAM BANERJEE
2015 年 10 月 31 日
コメント済み: SOHAM BANERJEE
2015 年 10 月 31 日
I have an excel program which contains different sheets and I need Matlab to read the data in each sheet one by one. I am required to put the file name (excel file) as an input and need Matlab to read the input variable. How do I do it?
0 件のコメント
採用された回答
Konstantinos Sofos
2015 年 10 月 31 日
Hi,
xlsfinfo will get you a list of sheet names into your Excel file.
[~,sheets] = xlsfinfo(filename);
A more elegant way (that I suggest) is to learn how to use ActiveX to parse data from your Excel e.g.
filename = 'C:\SomeExcelFile.xls';
% Open Excel Automation server
Excel = actxserver('Excel.Application');
% Make Excel visible
Excel.Visible=1;
% Open Excel file
Workbook = Excel.Workbooks.Open(filename);
% Get the list of sheets in the workbook
Sheets = Excel.ActiveWorkbook.Sheets;
% Save the file
Workbook.Save();
% Quit Excel, remove the COM server and delete the related objects
Excel.Quit();
Excel.delete();
A good starting point is here as reference Are there any examples that show how to use the ActiveX automation interface to connect MATLAB to Excel?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Use COM Objects in MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!