How can I connect a .m script to a GUI?

8 ビュー (過去 30 日間)
onamaewa
onamaewa 2019 年 10 月 16 日
回答済み: Jalaj Gambhir 2019 年 10 月 18 日
I know how to design a GUI interface through MATLAB, but I'm not sure how to connect my script to it.
My script is ~110 lines in length.
For a simplified case- let's say, I have this:
% X-axis
x = 1:1000;
% Y-axis
y = sin(x);
% Plotting Sine Wave
plot(x, y)
xlim([0 1000])
ylim([-1 1])
xlabel('Time (s)')
ylabel('Value (unit)')
In my GUI, I want user inputs to be:
x, y, xlim, ylim, etc.
How would I go about doing this?
I haven't found much transparency in how to go about connecting an extensive script into a GUI format.

回答 (1 件)

Jalaj Gambhir
Jalaj Gambhir 2019 年 10 月 18 日
Hi,
You can use App Designer to do the same. Firstly, you need to create Edit Fields for all the information that you want the user to input (ex, x,y xlim, ylim etc). You can then create a button and add it's callback to retrieve the values that were input. You can add the functionality of your script within the ButtonPush Callback as answered here.

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by