How to update rfplots

조회 수: 10 (최근 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 CenterFile Exchange에서 Specifying 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