MATLAB: How to plot ScopeData from Simulink into GUI

MATLABmatlab guisimulink

Simulating my model using
evalin('base','sim(''Gen_Diff_Model_2'')')
to bring the variable ScopeData1 to the base workspace. However when plotting the data using:
function Plot_Callback(hObject, eventdata, handles)
axes(handles.HV_Measurement);
plot(ScopeData1.time, ScopeData1.signals.values)
I receive: "Undefined function or variable 'ScopeData1'."
Thanks

Best Answer

Joe - since the ScopeData1 is in the base workspace, then you would need to use evalin from within your GUI to grab this data. For example,
function Plot_Callback(hObject, eventdata, handles)
axes(handles.HV_Measurement);
timeData = evalin('base','ScopeData1.time');
signalData = evalin('base','ScopeData1.signals.values');
plot(timeData, signalData);