MATLAB的UI轴内部的绘图bode的应用程序设计器

发布于 2025-01-25 05:27:54 字数 1093 浏览 0 评论 0原文

我正在应用应用程序设计器上创建一个UI,我想在我的UI.Axes中绘制一个bode。

此图包含两个图(幅度,相),我想做的是在不同的UI.axes中绘制每个曲线。

我设法使用以下代码绘制幅度bode

clc;
clear all;

num = [2];
den = [conv([1 1], conv([1 1], [1 1]))];
sys = tf(num, den);

[mag, phase, freq] = bode(sys, {0.1, 100});
bodemag(sys, freq)

h = bodeplot(sys, freq);
setoptions(h,'MagVisible','off');

此代码为我提供了这两个单独的图:

我正在尝试将这些图插入我的应用中的两个不同的UI轴。

有人对如何插入图有一个想法或其他方法吗?

nb:我已经尝试了以下操作: -

  • 将代码直接编写到应用程序设计器中,但它会创建 pop up 而不是
  • 使用 plot(app.uiaxes,,app.uiaxes, ....,....)功能,但我似乎无法使它起作用

I am creating a UI on app designer and I want to plot a bode in my UI.axes.

enter image description here

This figure contains two plots (magnitude, phase) and what I want to do is to plot each plot in different ui.axes.

I've managed to plot only the magnitude bode and the phase bode using the following code :

clc;
clear all;

num = [2];
den = [conv([1 1], conv([1 1], [1 1]))];
sys = tf(num, den);

[mag, phase, freq] = bode(sys, {0.1, 100});
bodemag(sys, freq)

h = bodeplot(sys, freq);
setoptions(h,'MagVisible','off');

This code gives me these two seperate plots :

enter image description here

enter image description here

I am trying to insert these plots in two different ui axes in my app.

Does any one have an idea or another approach on how to insert the plots ?

NB : I've tried the following :-

  • Writing the code direcly into the app designer but it creates a pop up instead
  • Using the plot(app.UiAxes, ...., ....) function but I can't seem to make it work

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

可爱暴击 2025-02-01 05:27:54

您可以通过app.uiaxes从appDesigner显示代码吗?
您使用哪种MATLAB Realease?
据我所知,在较旧版本的UIAXES中不支持子图。因此,您必须制作两个uiaxes或使用较新版本。

如果将代码直接写入AppDesigner,则将创建轴。 UIAXES和轴对象之间存在差异。如果要使用轴,则必须设置更多的属性,以使其在应用程序的Uifigure内部显示。
你尝试过吗?
我不知道UIAXES是否支持BODEMAG功能。如果不适合uiaxes,这可能是有道理的。

bode = bodemag(app.UIAxes,sys, freq);

如果UIAXES不支持BODEMAG,则必须使用正常轴进行编码并编码此轴的位置。
这是一个很好的示例。 “ nofollow noreferrer”> https://de.mathworks.com/help/matlab/creating_guis/polar-plotting-plotting-plotting-plotting-gui-in-app-designer.html

,这是需要附加的部分。

            % Create polar axes and position it in pixels
            app.Pax = polaraxes(app.UIFigure);
            app.Pax.Units = 'pixels';
            app.Pax.Position = [260 55 230 230];

Can you show your code from appdesigner with the app.UIAxes.
Which Matlab realease do you use ?
As i know subplots are not supported in a UIAxes in older versions. So you have to make two UIAxes or use newer version.

If you write your code directly to appdesigner you are creating an Axes. There is an difference between UIAxes and Axes object. If you want to use Axes you have to set more properties to make it display inside your UIFigure of your App.
You tried this ?
I don't know if the UIAxes supports bodemag function. This could make sense, if it doesn't work with UIAxes.

bode = bodemag(app.UIAxes,sys, freq);

If UIAxes doesn't support bodemag then you have to do it with normal axes and code the positioning of this axes.
This is a good example how to do it.: https://de.mathworks.com/help/matlab/creating_guis/polar-plotting-app-gui-in-app-designer.html

And this is the part that is required additional.

            % Create polar axes and position it in pixels
            app.Pax = polaraxes(app.UIFigure);
            app.Pax.Units = 'pixels';
            app.Pax.Position = [260 55 230 230];
记忆之渊 2025-02-01 05:27:54

appdesigner中的bode

        %% Bode Magnitude Plot  %%
        optMAG=bodeoptions;
        optMAG.PhaseVisible='off';
        bodeplot(app.BodeMagAxes,H,optMAG)

        %% Bode Phase Plot  %%
        opt=bodeoptions;
        opt.MagVisible='off';
        bodeplot(app.BodePhaseAxes,H,opt)

bode in appdesigner

        %% Bode Magnitude Plot  %%
        optMAG=bodeoptions;
        optMAG.PhaseVisible='off';
        bodeplot(app.BodeMagAxes,H,optMAG)

        %% Bode Phase Plot  %%
        opt=bodeoptions;
        opt.MagVisible='off';
        bodeplot(app.BodePhaseAxes,H,opt)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文