How to use multiple sliders to update variables

조회 수: 9 (최근 30일)
Bshara Murr
Bshara Murr 2017년 11월 21일
댓글: Bshara Murr 2017년 11월 23일
Hello i am building an application and i need to use sliders to allow the user to change some variables. I wrote a simple code to illustrate what i have done and what i am trying to do.
Slider = uicontrol('style','slide',...
'unit','pix',...
'position',[20 10 260 30],...
'min',0,'max',255,'val',255,...
'sliderstep',[1/255 5/255],...
'callback', @slidercallback);
function slidercallback(h, event)
x = 5;
y = get(h, 'value');
x+y
end
however i need to add another slider so i would be able to change the x value. Is there any possible way to pass values from the "slidercallback" into the first part of the script? or to another function that i might define? I have also tried to use addlistener. Thanks in advance.
  댓글 수: 2
Stephen23
Stephen23 2017년 11월 21일
Why not use one of the methods described in the MATLAB documentation?:
I would recommend using either nested functions or guidata.
Bshara Murr
Bshara Murr 2017년 11월 23일
Thank you so much. It works now.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by