How can i set dynamic axis limits in GUI?

5 ビュー (過去 30 日間)
BuzzLightyear
BuzzLightyear 2015 年 11 月 24 日
コメント済み: BuzzLightyear 2015 年 11 月 24 日
I want to create a map where I can set the upper axes limits with an editfield oder a slider.
function edit_x_Callback(hObject, eventdata, handles)
wert_x = str2double(get(handles.edit_x,'String'));
if (wert_x < 100) wert_x = 100;
elseif (wert_x > 10000) wert_x = 10000;
end
set(handles.edit_x,'String',wert_x);
set(handles.slider_x,'Value',wert_x);
set(handles.map,'Xlim','[0 wert_x]');
when editing the edit_x i get following errors:
Error using matlab.graphics.axis.Axes/set
While setting the 'XLim' property of 'Axes':
Value must be a 1x2 vector of numeric type in which the second element is larger than the first and may be
Inf
Error in uebung_slider>edit_x_Callback (line 122)
set(handles.map,'Xlim','[0 wert_x]');
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in uebung_slider (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)uebung_slider('edit_x_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
How can I fix the problem?

採用された回答

Jan
Jan 2015 年 11 月 24 日
Without quotes around the limits:
set(handles.map, 'Xlim', [0 wert_x]);

その他の回答 (1 件)

TastyPastry
TastyPastry 2015 年 11 月 24 日
Make sure wert_x is greater than 0, get rid of the single quotes around the vector. The 'xlim' property of an axes is a numeric type, not a char type.
  1 件のコメント
BuzzLightyear
BuzzLightyear 2015 年 11 月 24 日
Thanks alot, it works now without the quotes.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by