MATLAB App Designer fetch data from .m file

4 ビュー (過去 30 日間)
rohit
rohit 2020 年 8 月 27 日
コメント済み: Mehmed Saad 2020 年 8 月 28 日
I've a plot function in .m file. Can I plot the same figure inside App Designer with data being fetch from .m file continuously? How to achieve this?
For example, Suppose I've a test.m file and I want to plot it in App Designer.
function test
clc
global T
x=(0:.01:16);
y=sin(3*x);
T = figure(1);
hold all
Dx=50;y1=-1.2;y2=1.2;
for n=1:1:numel(x)
plot(x,y);axis([x(n) x(n+Dx) y1 y2]);
drawnow
end
end
Or Is it only possible to have a button in App designer and on clicking it, pop up figures appears?

採用された回答

Mehmed Saad
Mehmed Saad 2020 年 8 月 27 日
編集済み: Mehmed Saad 2020 年 8 月 27 日
if you call this function in app designer it will create an outside figure so you need to edit it a bit
You need to remove
T = figure(1)
hold all
add a UIAxes in you app
for hold on use
app.UIAxes.NextPlot = 'add';
Change this
plot(app.UIAxes,x,y);
app.UIAxes.XLim = [x(n) x(n+Dx)];
app.UIAxes.YLim = [y1 y2];
  2 件のコメント
rohit
rohit 2020 年 8 月 28 日
Can I not plot without making any changes in test.m file?
All necessary changes need to done in app designer only. Also, I want to call test.m in app designer, not copy the logic in app designer.
Mehmed Saad
Mehmed Saad 2020 年 8 月 28 日
if you want to plot it inside the app designer figure, then you need to make changes
if you just want to open a new figure, just write m file name in some button callback or in startup function. remember m file which you are calling must be added to matlab path

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by