Calls Matlab_app from Matlab_code to get data

1 Ansicht (letzte 30 Tage)
venkat ta
venkat ta am 2 Nov. 2023
Beantwortet: Sreeram am 9 Aug. 2024
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?

Antworten (1)

Sreeram
Sreeram am 9 Aug. 2024
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.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by