Matlab 如何从bode()获得第一个和第二个图
我知道如何使用Bode()函数创建Bode图。如果我想重叠两个或多个系统的频率响应,我使用Matlab 如何从bode()获得第一个和第二个图,matlab,Matlab,我知道如何使用Bode()函数创建Bode图。如果我想重叠两个或多个系统的频率响应,我使用 bode(sys1,sys2,...) 或 例如,当我想要到达绘图以放置带有text()的图例时,很容易到达第二个绘图。类似于图形指针的东西总是返回到第二个绘图(相位图) i、 例如,如果尝试以下几行: G = tf([1],[1 6]); figure(1); bode(G); text(10,-20,'text'); G = tf([1],[1 6]); figure(2); bode(G); te
bode(sys1,sys2,...)
或
例如,当我想要到达绘图以放置带有text()的图例时,很容易到达第二个绘图。类似于图形指针的东西总是返回到第二个绘图(相位图)
i、 例如,如果尝试以下几行:
G = tf([1],[1 6]); figure(1); bode(G); text(10,-20,'text');
G = tf([1],[1 6]); figure(2); bode(G); text(10,-20,'text');
当我返回到第一个图,使用图(1)并尝试
图例显示在第二个图(阶段图)中
我尝试了以下几行:
P = bodeoptions; % Set phase visiblity to off
P.PhaseVisible = 'off';
G = tf([1],[1 6]);
figure(1); bode(G,P); text(10,-20,'text');
figure(1); text(10,-20,'text');
如您所见,即使我关闭了相位图的可见性,图例也不会显示
本质上,我的问题是,我如何一个接一个地到达第一个和第二个情节?我尝试使用subplot(),但很明显,这不是Matlab跟踪这些绘图的方式
提前感谢。您可以使用以下方法分别获取每个系统的幅值和相位数据:
[mag,phase] = bode(sys,w)
现在,您可以使用
子绘图
或绘图
来绘制所需的图表。我能够执行的唯一解决方案是考虑轴位置。它不是很干净,但很管用。
以下是选择mag plot的代码:
ejes=findobj(get(gcf,'children'),'Type','axes','visible','on');
posicion=get(ejes,'pos');
tam=length(posicion);
for ii=1:tam
a=posicion{ii}(2);
vectorPos(ii)=a;
end
[valorMax,ind]=max(vectorPos); % min for choosing the phase plot
axes(ejes(ind))
这一切都是为了进入上层绘图,因为在
bodeplot
命令之后,下层绘图处于活动状态。直观地说,我们希望调用子图(2,1,1)
,但这只会在if的顶部创建新的空白图。因此,我们应该这样做:
% First, define arbitrary transfer function G(s), domain ww
% and function we want to plot on magnitude plot.
s = tf('s');
G = 50 / ( s*(1.6*s+1)*(0.23*s+1) );
ww = logspace(0,3,5000);
y = 10.^(-2*log10(ww)+log10(150));
hand = figure; % create a handle to new figure
h = bodeplot(G,ww);
hold on;
children = get(hand, 'Children') % use this handle to obtain list of figure's children
% We see that children has 3 objects:
% 1) Context Menu 2) Axis object to Phase Plot 3) Axis object to Magnitude Plot
magChild = children(3); % Pick a handle to axes of magnitude in bode diagram.
% magChild = childern(2) % This way you can add data to Phase Plot.
axes(magChild) % Make those axes current
loglog(ww,y,'r');
legend('transfer function','added curve')
使用figure(),Matlab指向第二个绘图(阶段)。i、 例如,G=tf([1],[16]);图(1);博德(G);text(10,-20,'text')G=tf([1],[16]);图(2);博德(G);text(10,-20,'text')我如何到达Mag绘图以便在(10,-20)中定位图例“text”?我编辑了原始答案您可以使用
Mag
使用普通绘图并执行任何您想要的操作。如果您有两个不同的图形,您可以将图形指针作为图形(图形编号)
在命令窗口中键入它似乎是bode()和bodeplot()将de Bode的图作为一个单元进行跟踪。如果我使用数字图,Matlab总是将这个图形单位指向第二个(最后一个对象)图。
ejes=findobj(get(gcf,'children'),'Type','axes','visible','on');
posicion=get(ejes,'pos');
tam=length(posicion);
for ii=1:tam
a=posicion{ii}(2);
vectorPos(ii)=a;
end
[valorMax,ind]=max(vectorPos); % min for choosing the phase plot
axes(ejes(ind))
% First, define arbitrary transfer function G(s), domain ww
% and function we want to plot on magnitude plot.
s = tf('s');
G = 50 / ( s*(1.6*s+1)*(0.23*s+1) );
ww = logspace(0,3,5000);
y = 10.^(-2*log10(ww)+log10(150));
hand = figure; % create a handle to new figure
h = bodeplot(G,ww);
hold on;
children = get(hand, 'Children') % use this handle to obtain list of figure's children
% We see that children has 3 objects:
% 1) Context Menu 2) Axis object to Phase Plot 3) Axis object to Magnitude Plot
magChild = children(3); % Pick a handle to axes of magnitude in bode diagram.
% magChild = childern(2) % This way you can add data to Phase Plot.
axes(magChild) % Make those axes current
loglog(ww,y,'r');
legend('transfer function','added curve')