在MATLAB GUI中,如何从GUIDE创建的.m文件中实现连续变化的滑块?

时间:2014-04-28 12:00:10

标签: matlab uislider matlab-guide

我尝试使用绘图和滑块创建GUI。滑块应按照herehere以及here所述继续输出。我对这些解释的问题是以编程方式创建uicontrol对象。相反,我想知道可以添加到GUIDE创建的.m文件中,以完成与前三个示例中以编程方式完成相同的操作。代码如下,并且我已经标记了上面某些示例提供的(错误)代码。非常感谢您的帮助!

%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

%BEGINend之间的界限是我遇到麻烦的地方。我得到的错误信息是

??? Undefined function or method 'findjobj' for input arguments of type 'double'.
Error in ==> first>P1_slider_CreateFcn at 204
    jScrollBar = findjobj(hObject);

0 个答案:

没有答案