How to automically read data from excel file

2 Ansichten (letzte 30 Tage)
Chao Zhang
Chao Zhang am 20 Mai 2021
Beantwortet: Cris LaPierre am 20 Mai 2021
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?

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 20 Mai 2021
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.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by