Plot impedance chart into an axes

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.

 采纳的回答

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 个评论

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)

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Axis Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by