Hello friends, I hope you can help me with my code problem. I'm trying plot the impedance chart into an axes in a GUI, like this:
axes(handles.axes2);
impedance(di,linspace(50e6,f*10^6,51));
legend('Resistencia','Reactancia');
title('Impedancia');
ylabel('Impedancia (ohms)');
grid;
But the chart plots using all the window GUI figure. How can I plots the inpedance chart into the axes2?
Thanks in advance for your replies.

 Accepted Answer

Adam Danz
Adam Danz on 6 Feb 2021
Edited: Adam Danz on 9 Feb 2021
I have a feeling you're working with a uifgure instead of the regular figures.
HandleVisibility of uifigures needs to be on to plot on current axes within the uifigure.
uif = uifigure();
% ax = axes(uif);
ax = uiaxes(uif);
set(0,'CurrentFigure',fig)
uif.CurrentAxes = ax;
uif.HandleVisibility = 'on';
impedance(di,linspace(50e6,f*10^6,51));
uif.HandleVisibility = 'off';
legend(ax, 'Resistencia','Reactancia');
title(ax, 'Impedancia');
ylabel(ax, 'Impedancia (ohms)');
grid(ax, 'on')

4 Comments

Hello Adam Danz, thanks for your reply, you are so kind. I tried your code but I have an error:
Error using axes
Functionality not supported with figures created with the uifigure function.
What it means? Thanks in advace.
What release of Matlab are you using?
That information is important to include in your question.
Replace this line
ax = axes(uif)
With this one
ax = uiaxes(uif)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!