Load function in script not saving to Workspace
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a nueral network saved in a mat file- Net.Mat, I want to load this network, so I've put the load function in a pushbutton call back. However, when I click on the button, the network isnt showing up in the workspace. When I double click on the Net.mat file, my network shows in the workspace. But not when the load function is executed as a part of the code for my pushbutton.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load Net;
handles.net=net;
set(handles.pushbutton3,'Enable','on');
set(handles.pushbutton5,'Enable','on');
0 Kommentare
Antworten (1)
Stephen23
am 2 Mai 2018
Bearbeitet: Stephen23
am 2 Mai 2018
"However, when I click on the button, the network isnt showing up in the workspace"
Yes it is. It will be loaded into the callback workspace. Every function (and this includes callback functions) have their own independent workspace. So when you load into that workspace, that is where you can find it. If you want to pass that data into another workspace, then you will need to pass that data, as is explained in the MATLAB documentation:
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
S = load('Net.mat');
handles.net = S.net;
set(handles.pushbutton3,'Enable','on');
set(handles.pushbutton5,'Enable','on');
guidata(hObject,handles) % you need this line!
end
And then the field .net will be available anywhere where you can access handles.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!