简体   繁体   English

在 Matlab 应用程序设计器的 UI 轴内绘制预兆

[英]Plot bode inside UI axes of Matlab's app designer

I am creating a UI on app designer and I want to plot a bode in my UI.axes.我正在应用程序设计器上创建一个 UI,我想在我的 UI.axes 中绘制一个预兆。

在此处输入图像描述

This figure contains two plots (magnitude, phase) and what I want to do is to plot each plot in different ui.axes.该图包含两个图(幅度,相位),我想做的是在不同的 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 :这段代码给了我这两个单独的图:

在此处输入图像描述

在此处输入图像描述

I am trying to insert these plots in two different ui axes in my app.我试图在我的应用程序的两个不同的 ui 轴中插入这些图。

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使用plot(app.UiAxes, ...., ....)函数,但我似乎无法使其工作

Can you show your code from appdesigner with the app.UIAxes.您可以使用 app.UIAxes 显示来自 appdesigner 的代码吗? Which Matlab realease do you use ?您使用哪个 Matlab 版本? As i know subplots are not supported in a UIAxes in older versions.据我所知,旧版本的 UIAxes 不支持子图。 So you have to make two UIAxes or use newer version.所以你必须制作两个 UIAxes 或使用更新的版本。

If you write your code directly to appdesigner you are creating an Axes.如果您直接将代码编写到 appdesigner,那么您正在创建一个轴。 There is an difference between UIAxes and Axes object. UIAxes 和 Axes 对象之间存在差异。 If you want to use Axes you have to set more properties to make it display inside your UIFigure of your App.如果您想使用 Axes,您必须设置更多属性以使其显示在您的应用程序的 UIFigure 中。 You tried this ?你试过这个? I don't know if the UIAxes supports bodemag function.我不知道 UIAxes 是否支持 bodemag 功能。 This could make sense, if it doesn't work with UIAxes.如果它不适用于 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.如果 UIAxes 不支持 bodemag,那么您必须使用普通轴并编码此轴的定位。 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这是一个很好的例子。: 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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM