uicontrol callback function with single variable
조회 수: 2 (최근 30일)
이전 댓글 표시
I am trying to create a GUI that will have multiple pushbuttons which I want to reference the same callback function with the caveat being that the only piece that changes in the callback function is a single variable which I want to pass to the function in the syntax for the uicontrol. For example, lets say i have the following uicontrols
%pushbutton for 1x line bet
uicontrol('Parent',display,...
'Style','pushbutton',...
'String','1x',...
'Units','normalized',...
'Position',[0.8,0.70,0.15,0.06],...
'Callback',{@test,1});
%pushbutton for 2x line bet
uicontrol('Parent',display,...
'Style','pushbutton',...
'String','2x',...
'Units','normalized',...
'Position',[0.8,0.60,0.15,0.06],...
'Callback',{@test,2});
%pushbutton for 5x line bet
uicontrol('Parent',display,...
'Style','pushbutton',...
'String','3x',...
'Units','normalized',...
'Position',[0.8,0.50,0.15,0.06],...
'Callback',{@test,3});
and lets say this is my callback function
function test(multiple)
x = [0,1,2,3];
y = multiple .* x
end
I've tried it both the way that I have it shown in my example as well as changing the syntax for the callback function to function test(multiple, ~) and the uicontrol syntax to {@test,1,~} for example with no sucess either way. Both cases give me an error that says I have too many input arguments. Can anyone tell me what I'm doing wrong?
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!