2017-12-08 5 views
0

私はscilabで単純なGUIを作成しようとしていますが、関数a'sin(x)のグラフを表示するために、スライダが "a"の値を駆動しています。私は "a"の現在の値に対応するカーブだけを表示する方法を見つけられないようです...既存のカーブに新しいカーブを追加するだけです。私はこれ以上簡単に解決できないことを願っています(Mathematicaの経験があるだけです)。私が使用する非常に簡単なコードは次のとおりです。Scilab - gui-axes auto_cleanスライダ調整中のグラフ...?

// This GUI file is generated by guibuilder version 3.0 
////////// 
f=figure('figure_position',[400,50],'figure_size', 
[656,581],'auto_resize','on','background',[33],'figure_name','Graphic 
window number %d'); 
////////// 
delmenu(f.figure_id,gettext('File')) 
delmenu(f.figure_id,gettext('?')) 
delmenu(f.figure_id,gettext('Tools')) 
toolbar(f.figure_id,'off') 
handles.dummy = 0; 
handles.slider=uicontrol(f,'unit','normalized','BackgroundColor', 
[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma', 
'FontSize',[12],'FontUnits','points','FontWeight','normal', 
'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop', 
[],'Max',[1],'Min',[0],'Position',[0.0359375,0.78125,0.2625,0.09375], 
'Relief','default','SliderStep', 
[0.01,0.1],'String','slider1','Style','slider','Value', 
[0],'VerticalAlignment','middle','Visible','on','Tag','slider', 
'Callback','slider_callback(handles)') 
handles.graph= newaxes();handles.graph.margins = [ 0 0 0 
0];handles.graph.axes_bounds = [0.31875,0.01875,0.6640625,0.925]; 

////////// 
// Callbacks are defined as below. Please do not delete the comments as 
it will be used in coming version 
////////// 

function slider_callback(handles) 
//Write your callback for slider here 
x=0:0.1:10; 
a=handles.slider.Value; 
plot(x,a*sin(x)); 
endfunction 

ありがとうございます。

答えて

1

デフォルトでは、各グラフィック命令はその結果を現在のディスプレイに追加します 新しいグラフィック命令が表示される前に図を自動的に消去したい場合は、軸の自動クリアプロパティを "オン"に設定できます。他の解決策は、削除機能を使用して前の図面を消去することです。

あなたは目盛があなた​​の代わりに、プロット関数の答えを

// This GUI file is generated by guibuilder version 3.0 
////////// 
f=figure('figure_position',[400,50],'figure_size',... 
[656,581],'auto_resize','on','background',[33],'figure_name','Graphic window number %d'); 
////////// 
delmenu(f.figure_id,gettext('File')) 
delmenu(f.figure_id,gettext('?')) 
delmenu(f.figure_id,gettext('Tools')) 
toolbar(f.figure_id,'off') 
handles.dummy = 0; 
handles.slider=uicontrol(f,'unit','normalized','BackgroundColor',... 
[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma',... 
'FontSize',[12],'FontUnits','points','FontWeight','normal',... 
'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop',... 
[],'Max',[1],'Min',[0],'Position',[0.0359375,0.78125,0.2625,0.09375],... 
'Relief','default','SliderStep',... 
[0.01,0.1],'String','slider1','Style','slider','Value',... 
[0],'VerticalAlignment','middle','Visible','on','Tag','slider',... 
'Callback','slider_callback(handles)') 
handles.graph= newaxes(); 
handles.graph.margins = [ 0 0 0 0]; 
handles.graph.axes_bounds = [0.31875,0.01875,0.6640625,0.925]; 
handles.graph.data_bounds=[0 -1.2;10 1.2]; 
handles.graph.auto_clear="on"; 
////////// 
// Callbacks are defined as below. Please do not delete the comments as 
//it will be used in coming version 
////////// 

function slider_callback(handles) 
//Write your callback for slider here 
x=0:0.1:10; 
a=handles.slider.Value; 
drawlater() 
//delete(handles.graph.children) 
xpoly(x,a*sin(x)) 
handles.graph.data_bounds=[0 -1.2;10 1.2]; 
drawnow 
//plot(x,a*sin(x)); 
endfunction 
+0

感謝をxpoly機能を使用することができ、表示させたくない場合は、それが動作します。また、xpolyを使用してx軸とy軸を表示するにはどうしたらいいですか?もし、auto_clear = onのplot()関数を2〜3回動かせば、エラー "! - error 999 がセットされます:ハンドルが有効ではありません。 ...私は本当に理由を理解していない... – Conrad

関連する問題