MATLAB: I am trying to make a GUI where the user can input an excel file with data that will be used in the calculation. How to go about this

excelguiimporting excel datamatlab gui

Note: I am not trying to upload it myself, I need the user to be able to do this when they are using the GUI.

Best Answer

See this snippet:
% Have user browse for a file, from a specified "starting folder."
% For convenience in browsing, set a starting folder from which to browse.
startingFolder = 'C:\Program Files\MATLAB'; % Wherever you want...
if ~exist(startingFolder, 'dir')
% If that folder doesn't exist, just start in the current folder.
startingFolder = pwd;
end
% Get the name of the file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.xls*');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
[numbers, strings, rawData] = xlsread(fullFileName);