2017-09-28 43 views

回答

3

看看demo_uicontrol.m其中有你所需要的:

demo_uicontrol screenshot

一个精简例如,对于你问什么 “滑块靠近我的阴谋”

## Useful since Octave 4.0 

close all 
clear h 

graphics_toolkit qt 

h.ax = axes ("position", [0.05 0.42 0.5 0.5]); 

function update_plot (obj, init = false) 

    ## gcbo holds the handle of the control 
    h = guidata (obj); 

    a = get (h.slider1, "value"); 
    w = get (h.slider2, "value"); 
    x = linspace (0, 3); 
    y = a * sin (x * 5 * w); 

    if (init) 
    h.plot = plot (x, y, "b"); 
    else 
    set (h.plot, "xdata", x); 
    set (h.plot, "ydata", y); 
    endif 
    guidata (obj, h); 

endfunction 

h.slider1 = uicontrol ("style", "slider", 
         "units", "normalized", 
         "string", "slider", 
         "callback", @update_plot, 
         "value", 0.4, 
         "position", [0.05 0.25 0.35 0.06]); 

h.slider2 = uicontrol ("style", "slider", 
         "units", "normalized", 
         "string", "slider", 
         "callback", @update_plot, 
         "value", 0.7, 
         "position", [0.05 0.15 0.35 0.06]); 

set (gcf, "color", get(0, "defaultuicontrolbackgroundcolor")) 
guidata (gcf, h) 
update_plot (gcf, true); 

demo2