I assume that you are trying to access the value user selected in the slider in MATLAB script. However, you are getting default value of 1 from the slider, multiplying it by [10 1], and getting outdata as [10 1]. This is because, your script isn’t waiting for the user to select a value.
Since it is a slider, it passes through intermediary values before reaching the final value the user wants to reach. To allow the user to choose the value and proceed with the script, you may add an “OK” button to the UI.
To access the value selected by the user in the slider in the MATLAB script, you may do the following:
- Drag and drop a “Button” from “Component Library” onto your app besides the slider and label it “OK”.
- Right-click on the button, hover over “Callbacks”, and select “Add ButtonPushedFcn callback”. You’ll now be in Code View. Add the following line in the function body:
- In the MATLAB script, add this line just before outdata = Murugan.func();:
uiwait(Murugan.UIFigure);
This will make the script wait until it is resumed (which will happen when you click the OK button).
You can refer to the documentations for uiwait and uiresume here:
Hope this helps.