Clear Filters
Clear Filters

Calls Matlab_app from Matlab_code to get data

18 views (last 30 days)
venkat ta
venkat ta on 2 Nov 2023
Answered: Sreeram on 9 Aug 2024 at 3:19
clear all; close all; clc;
Murugan = app1();
outdata = Murugan.func();
Calls Matlab_app from Matlab_code to get slider moving data
The object function works in Matlab_code because it contains one of the data in the outdata except changing the slider data
Can you point out my mistake?

Answers (1)

Sreeram
Sreeram on 9 Aug 2024 at 3:19
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:
uiresume(app.UIFigure);
  • 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.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!