MATLAB: Automatic Callback creation for UI Button

MATLABmatlab guiuibutton

Hello there.I have a loop that automatically creates UI buttons based on a file that is read and the amount of instances in the file. I would like to now access those callbacks (or essentially make them) while in the loop. How can I go about this?
I am using MATLAB 202a.

Best Answer

You can use the ButtonPushedFcn property of the uibutton to assign it a callback. For example
btn = uibuttin();
btn.ButtonPushedFcn = @function_handle_name