2017-09-28 4 views
0

私のプロットの近くにスライダを作成し、そのパラメータとやりとりする必要があります。 誰かが同じ数字でそれをどのように作成し、それにスライダパラメータの名前と値を近づけ、それを私のプロットにリンクする方法を説明できますか?OCTAVE-私のプロット(別の図で描かれている)のパラメータを変更するインタラクティブなSLIDERSを配置する図を作成します。

ありがとうございました。

+0

を求めてきました何のために例を剥奪しましたあなたはGUIが必要なように聞こえる - オクターブには「GUIDE」機能がありますか? – etmuse

答えて

3

はあなたが必要なすべてを持っているdemo_uicontrol.mを見て:

demo_uicontrol screenshot

Aは、あなたが "私のプロットの近くにスライダー"

## 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

関連する問題