How to update rfplots

16 ビュー (過去 30 日間)
Henning
Henning 2024 年 1 月 24 日
編集済み: Hassaan 2024 年 1 月 26 日
I'm using the rfplot command from the RF Toolbox create a s-parameter visualization GUI. (App Designer)
"hold on" is used to plot several parameters in one figrue.
On some points, the plots have to be updated. For instance, if the user wants to delete a parameter.
The problem is how to reset these plots?
hold(app.AxesMag, 'on');
rfplot(app.AxesMag,app.s2p1,{[app.n(1),app.n(2)]});
rfplot(app.AxesMag,app.s2p2,{[app.n(1),app.n(2)]});
hold(app.AxesMag, 'off');
This works fine, but if the plots are to be updated, they will be added to the old ones. My question is how to reset the figure? Resetting/Clearing the Axes via "clf" or "cla" does not work.

回答 (2 件)

Hassaan
Hassaan 2024 年 1 月 24 日
% Clear the axes
cla(app.AxesMag);
% Hold on for multiple plots
hold(app.AxesMag, 'on');
% Plot your s-parameters
rfplot(app.AxesMag, app.s2p1, {[app.n(1), app.n(2)]});
rfplot(app.AxesMag, app.s2p2, {[app.n(1), app.n(2)]});
% Release hold
hold(app.AxesMag, 'off');
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.
  2 件のコメント
Adam Danz
Adam Danz 2024 年 1 月 25 日
> Resetting/Clearing the Axes via "clf" or "cla" does not work
This answer is not helpful. Your answer just copies the same code from the question and then uses cla which the OP claims isn't working.
@Muhammad Hassaan Shah please review the Generative AI guidelines for MATLAB Central
The use of generative AI tools is allowed but you are responsible for ensuring that your content is relevant and accurate.
Hassaan
Hassaan 2024 年 1 月 26 日
編集済み: Hassaan 2024 年 1 月 26 日
Thank you for the valuable feedback and much appreciated for the referred link.

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


Adam Danz
Adam Danz 2024 年 1 月 24 日
I'm not quite sure how to interpret the problem. Here are two guesses.
> if the plots are to be updated, they will be added to the old ones
If you are trying to add more lines to the existing axes, use hold(app.AxesMag,'on') or remove the hold(app.AxesMag,'off').
If you are trying to update the line objects, add an output to the rfplot function. The output is a handle array of line handles. The line handles contain XData and YData properties that can be updated.
> My question is how to reset the figure? Resetting/Clearing the Axes via "clf" or "cla" does not work.
If the goal is the clear the axes, cla does work and if the goal is to clear the figure, clf does work so I would need more details on what's not working.
  4 件のコメント
Henning
Henning 2024 年 1 月 26 日
Unfortunately your suggestion doesn't work as well.
It may helps if I desicirbe the goal of the app more:
In a first step, the purpose is to visualize s-parameters of up to three touchstone files simultaniously. These are imported and stored in Matlab, and can be selected to be shown by the user via check boxes. A button displays all desired plots via callback. Up to this point, everything works well. The next step would be to be able to change adjustments, e.g. display a different parameter without restarting the app. Because I'm using hold on, the plots are added to the existing ones, but I don't want that. Therefore, I want to reset them. That is also what I ment with refesh the plots. The simpliyfied code is:
function UpdatePlotButtonPushed(app, event) %button callback to update the plot
rfplot(app.AxesMag,app.s2p1,{[app.n(1),app.n(2)]});
function ClearButtonPushed(app, event)
cla(app.AxesMag,'reset');
function UpdatePlotButtonPushed(app, event) %button callback to update the plot
rfplot(app.AxesMag,app.s2p1,{[app.n(1),app.n(2)]});
While second time the rfplot is executed, the mentioned error message appears. I tried every cla, clf, delete combination I found. Implementing static plot names for the legend do not help either.
Hassaan
Hassaan 2024 年 1 月 26 日
編集済み: Hassaan 2024 年 1 月 26 日
Reference
> Resetting/Clearing the Axes via "clf" or "cla" does not work
Any answer/solution provided that does not solves OP query is 'Generative AI' I dont know how.
As per OP:
'Unfortunately your suggestion doesn't work as well.'
This answer is not helpful. Your answer just copies the same code from the question/comments with slight argument change and then uses cla which the OP claims isn't working.
@Adam Danz please review and guide further.
AI Guidelines:
I hope other senior members of MATLAB community can shed some light on this. And better define 'Do's and Don't' for 'Generative AI' usage and defination for the MATLAB QnA community. Instead, of marking and assumming every other answer as 'Generative AI'.

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

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by