How to automically read data from excel file

1 回表示 (過去 30 日間)
Chao Zhang
Chao Zhang 2021 年 5 月 20 日
回答済み: Cris LaPierre 2021 年 5 月 20 日
I am newer to learn Matlab, so I would like to ask for some help.
I use 'menu' function to create 3 buttons, such as 'A', 'B', and 'exit the program', and I want to automically select and read the dataset of different excel files when users click button A or B, and users then can use the dataset in the workspace to do some computations.
For this purpose, i then create function A and function B respectively, the following example is function A:
function A(data, position)
%data.name is the appropriate excel file, pathname is the position of file
%specifies the type of file that can be selected
[data.filename, pathname]=...
uigetfile({'*.xlsx';'*.xls';'*.*'},'File Selector');
pathname=string(pathname);
data.filename=string(data.filename);
if isequal(data.filename,0)||isequal(pathname,0)
return
else
data.fileText.Value=pathname+data.filename;
end
but i have no idea how to read the dataset and use them after i run this code and select the excel file,
so how to accomplish this goal?

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 5 月 20 日
I suggest using readtable to import a spreadsheet. See here.
As for what to do with the data once you've imported it, I suggest MATLAB Onramp.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by