Hello, I have a really annoying error that i can't find a way to make it work, my code looks like this:
function [h] = test_listeners()f = figure('Units','Normalized');h.Red = uicontrol('Parent',f,... 'Units','Normalized',... 'Style','slider',... 'position',[0.1, 0.6, 0.3, 0.1],... 'backgroundColor',[1,0.85,0.85],... 'FontSize',15);h.Blue = uicontrol('Parent',f,... 'Units','Normalized',... 'Style','text',... 'position',[0.1, 0.3, 0.3, 0.1],... 'backgroundColor',[0.85,0.85,1],... 'FontSize',15);addlistener(h.Red,'Action',@()callbackBlue(h.Blue));endfunction [] = callbackBlue(varargin)disp(varargin)end
in one sentence it should change the value of BLUE according to the value of RED, but even though in input of the callback is varargin when running the code i get this error message:
Warning: Error occurred while executing thelistener callback for event Action definedfor class matlab.ui.control.UIControl:Error usingtest_listeners>@()callbackBlue(h.Blue)Too many input arguments.
I am currently stuck and will love some help.
Best Answer