I'm trying to create a GUI with a plot and a slider. The slider should be continuously outputting as described here and here and here. The problem I'm having with these explanations is that the uicontrol
object is created programatically. In contrast, I'd like to know what can be added to the GUIDE created .m-file to accomplish the same thing as is done programatically in the previous three examples. The code is below, and I've flagged the (wrong) code that is provided by some of the examples above. Thanks very much for any help!
%this runs the slider
function P1_slider_Callback(hObject, eventdata, handles)
set(handles.P1val, 'String', num2str(get(hObject,'Value'), 3))
PlottheData_Callback(hObject, eventdata, handles)
%"PlottheData" is a button that plots data depending on the value of P1_slider
%this creates the slider, and I guess the "making continuous" needs to happen here
function P1_slider_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
%BEGIN WRONG CODE! HELP HERE PLEASE!
jScrollBar = findjobj(hObject);
jScrollBar.AdjustmentValueChangedCallback = @myCbFcn;
hhSlider = handle(hObject);
hProp = findprop(hhSlider,'Value'); % a schema.prop object
hListener = handle.listener(hhSlider,hProp,'PropertyPostSet',@myCbFcn);
setappdata(hhSlider,'sliderListener',hListener); % this is important - read above
end
The lines between %BEGIN
and end
are where I'm having trouble. The error message I get is
??? Undefined function or method 'findjobj' for input arguments of type 'double'.
Error in ==> first>P1_slider_CreateFcn at 204
jScrollBar = findjobj(hObject);