フィルターのクリア

How to continue a plot in app designer with a push button?

12 ビュー (過去 30 日間)
Davide Mastrodicasa
Davide Mastrodicasa 2020 年 1 月 24 日
Hello everyone. I'm new in appdesigner and I need a help to solve this problem:
I have a for loop that plots me each column of a matrix and I would like to continue the plot with a push Button. From this link https://it.mathworks.com/matlabcentral/answers/473457-button-press-to-continue-iteration-in-appdesigner the possible solution seems to be uiwait and uiresume but I'm not able to use them properly.
This is my code:
function FRFOMACalculationButtonPushed(app, event)
% Code lines....
for ch = 1:size(app.H.H,1)
app.Panel.AutoResizeChildren = 'off';
ax1=subplot(3,1,[1 2],'Parent',app.Panel);
semilogy(ax1,app.H.f,abs(squeeze(app.H.H(ch,1,:))));
ylabel(ax1,'Magnitude'); xlim(ax1,[app.f1 app.f2])
ax2=subplot(3,1,3,'Parent',app.Panel);
plot(ax2,app.H.f,angle(squeeze(app.H.H(ch,1,:))));
xlabel(ax2,'f [Hz]'); ylabel(ax2,'Phase'); xlim(ax2,[app.f1 app.f2]);
uiwait(ax1);
uiwait(ax2);
end
% Code lines....
end
For the callback of the button i have:
function ButtonNextPushed(app, event)
uiresume(ax1);
uiresume(ax2);
end
It doesn't work and I don't know how to solve it.
I hope the question is clear. Thank you in advance.

採用された回答

Geoff Hayes
Geoff Hayes 2020 年 1 月 24 日
Davide - rather than waiting and resuming, since all subsequent updates to the axes occur with the press of a button, just put all that update logic in a helper function that is called by both FRFOMACalculationButtonPushed and ButtonNextPushed. Perhaps something like
function FRFOMACalculationButtonPushed(app, event)
% some code to do calculations?
% update the axes
app.H.ch = 1; % I'm not sure if this is valid (never used AppDesigner)
UpdatePlot(app);
end
function ButtonNextPushed(app, event)
UpdatePlot(app);
end
function UpdatePlot(app)
if app.H.ch <= size(app.H.H,1)
ch = app.H.ch;
app.Panel.AutoResizeChildren = 'off';
ax1=subplot(3,1,[1 2],'Parent',app.Panel);
semilogy(ax1,app.H.f,abs(squeeze(app.H.H(ch,1,:))));
ylabel(ax1,'Magnitude'); xlim(ax1,[app.f1 app.f2])
ax2=subplot(3,1,3,'Parent',app.Panel);
plot(ax2,app.H.f,angle(squeeze(app.H.H(ch,1,:))));
xlabel(ax2,'f [Hz]'); ylabel(ax2,'Phase'); xlim(ax2,[app.f1 app.f2]);
app.H.ch = app.H.ch + 1; % I'm not sure if this is valid (never used AppDesigner)
end
end
The above should avoid the need to use wait and resume. I'm just not sure on the syntax of updating variables in the app object. Perhaps the above is sufficient. If not, hopefully it is enough to get an idea of what you could do.
  1 件のコメント
Davide Mastrodicasa
Davide Mastrodicasa 2020 年 1 月 27 日
Geoff,
Thank you very much for your suggestion. I solved the problem following your answer.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by