Hello,
In my code I have a Push Button, that will stay open during code execution. The user may use the push button; and that will pass some values to a function.
The function runs fine when run on it's own, with a call that looks like
function(input1,input2,input3)
In the code fo the push button, the format is this:
ButtonHandle2 = uicontrol(figure1,'Style','PushButton','Callback',@function)
I am not conceptually strong on buttonhandles (this is my first day using them), nor on function handles '@', and to me I originally thought one of these two should have happened:
ButtonHandle2 = uicontrol(figure1,'Style','PushButton','Callback',function(input1,input2,input3))
-OR-
f = @function(input1,input2,input3) ButtonHandle2 = uicontrol(figure1,'Style','PushButton','Callback',f)
However, neither of the two even executed. The format posted above actually executed the function, and I got this error:
Operator '-' is not supported for operands of type 'matlab.ui.eventdata.ActionData'.Error in speedselect (line 6) min_diff = abs(speedarray(1) - speed);Error while evaluating UIControl Callback.
Since this is saying that the subtraction itself is not supported, I suppose the issue here is that I don't have enough familiarity with using callback functions with MATLAB and I couldn't see anything online that says that subtraction/addition is not supported, so I think it's a usage issue by me. I can easily work around this error with different structures of code, but I am curious to learn more about this conceptually. Please let me know if you can point out what I am doing wrong, and if this requires seeing more of my relevent code, I can post it.
Best Answer