Calls Matlab_app from Matlab_code to get data

1 visualización (últimos 30 días)
venkat ta
venkat ta el 2 de Nov. de 2023
Respondida: Sreeram el 9 de Ag. de 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?

Respuestas (1)

Sreeram
Sreeram el 9 de Ag. de 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.

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by