How to automically read data from excel file

1 view (last 30 days)
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?

Accepted Answer

Cris LaPierre
Cris LaPierre on 20 May 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.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!