필터 지우기
필터 지우기

¿How can I transform an already working code to a GUI?

조회 수: 41 (최근 30일)
José Felipe Serna
José Felipe Serna 2024년 7월 30일 12:27
편집: Pavan Sahith 2024년 7월 31일 8:18
I have a code that works fine and gives me the expected outputs. I don´t know how to transform that code into an app that asks me for the inputs and returns the plot of such result.

채택된 답변

Pavan Sahith
Pavan Sahith 2024년 7월 30일 13:40
편집: Pavan Sahith 2024년 7월 31일 8:18
Hello Jose,
I think there isn't a fully automated way to convert MATLAB code directly into an app, but MATLAB App Designer provides a straightforward environment to manually create an app that leverages your existing code.
For example, if you have a MATLAB function that takes two inputs and generates a plot:
function myFunction(input1, input2)
x = linspace(-10, 10, 100);
y = input1 * x + input2;
plot(x, y);
title('Result Plot');
xlabel('X-axis');
ylabel('Y-axis');
end
In App Designer, you can use some components and add callbacks which call your function:
  1. Add two Numeric Edit Field components for the inputs.
  2. Add a Button component to trigger the calculation.
  3. Add an Axes component to display the plot.
To learn how to call a function from within a callback, you can refer to these similar MATLAB Answers:
You can also refer to this documentation to know more about how to create a simple app:
Hope this helps you in moving forward
  댓글 수: 1
José Felipe Serna
José Felipe Serna 2024년 7월 30일 16:31
Thanks a lot for your time and explanation! I will try that method!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

SACHIN KHANDELWAL
SACHIN KHANDELWAL 2024년 7월 30일 13:11
I understand that you want to create an app that follows the desired workflow. I would recommend utilizing the MATLAB App Designer feature for your use case.
If you would like to learn more about App Designer, you might find the following MathWorks Onramp course helpful:
Additionally, you can explore how to create a simple app by referring to this documentation:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by