Import excel data from GUI to MATLAB workspace?

2 views (last 30 days)
I am creating a GUI that imports a file selected by the user, displays the data selected, loads the data selected into the MATLAB workspace and then runs a script that correlates the data. I have an issue in that I don't know how to import the data from the GUI into the workspace. Any help on how to do this would be greatly appreciated.
This is the GUI so far
GUI_v1.PNG
The code for the two pushbuttons is the same, only changing the numbers between them.
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[aa,data_path] = uigetfile('*.xlsx','Source Data Files','MultiSelect', 'on');
[~, ~, Normname] = xlsread([data_path,aa],'Sheet1');
Normname(cellfun(@(x) ~isempty(x) && isnumeric(x) && isnan(x),Normname)) = {''};
set(handles.NNTable1,'data',Normname)
This takes the excel file selected and displays it in the mini spreadsheet shown there.
The correlate button is coded to run the correlation test but if I don't have the data in the workspace it can't run.
Any help on how to get the data from the table to the workspace would be much appreciated

Answers (0)

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!