Calls Matlab_app from Matlab_code to get data

조회 수: 1 (최근 30일)
venkat ta
venkat ta 2023년 11월 2일
답변: Sreeram 2024년 8월 9일
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?

답변 (1개)

Sreeram
Sreeram 2024년 8월 9일
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.

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by