How to remove the number caused by 'grid on' and How to change the legend mark
1 次查看(过去 30 天)
显示 更早的评论
I want to draw the pole-zero map of the specific system. This is my code:
-------------
close all;
clear;
clc;
w0=300;
l1=2*w0;
l2=w0^2;
k=60;
s=tf('s');
r=[0.9,1.2,1.3,1.4,1.8,2.5,3.5];
H=figure;
for i=1:7
transfer_function=k*(s^2+l1*s+l2)/(r(i)*s^3+r(i)*(l1+k)*s^2+(k*l1+l2)*s+k*l2);
pzmap(transfer_function)
hold on;
end
s=findobj(gcf,'Type','Axes');
title('');
set(s,'XLim',[-300,0],'YLim',[-60,60],'XColor',[0,0,0],'YColor',[0,0,0],'XGrid','off','YGrid','off','GridLineStyle','--','YTick',[-60 -40 -20 0 20 40 60]);
set(s.XLabel,'FontSize',12,'FontName','TimesNewRoman');
set(s.YLabel,'FontSize',12,'FontName','TimesNewRoman');
linewidth=1.5;
set(s.Children(1).Children(1),'LineWidth',linewidth,'Color','#ESAD00');
set(s.Children(1).Children(2),'LineWidth',linewidth,'Color','#7C6FAF');
set(s.Children(2).Children(2),'LineWidth',linewidth,'Color','#AA7816');
set(s.Children(3).Children(2),'LineWidth',linewidth,'Color','#EE6C1B');
set(s.Children(4).Children(2),'LineWidth',linewidth,'Color','#E02F12');
set(s.Children(5).Children(2),'LineWidth',linewidth,'Color','#75AB43');
set(s.Children(6).Children(2),'LineWidth',linewidth,'Color','#238392');
set(s.Children(7).Children(2),'LineWidth',linewidth,'Color','#0728E4');
grid on;
legend('r=3.5','r=2.5','r=1.8','r=1.4','r=1.3','r=1.2','r=0.9');
------------
I tried to usd 'pzmap' and 'pzplot' to draw the graph, and once the 'grid on' and 'legend' are used. The grid and the number which is undired, look this picture. And the legend is linear which is not 'x'.

I want to draw a graph like this:

How should I do?
1 个评论
Walter Roberson
2024-7-23
Fixing the 'ES' to 'E5'...
close all;
clear;
clc;
w0=300;
l1=2*w0;
l2=w0^2;
k=60;
s=tf('s');
r=[0.9,1.2,1.3,1.4,1.8,2.5,3.5];
H=figure;
for i=1:7
transfer_function=k*(s^2+l1*s+l2)/(r(i)*s^3+r(i)*(l1+k)*s^2+(k*l1+l2)*s+k*l2);
pzmap(transfer_function)
hold on;
end
s=findobj(gcf,'Type','Axes');
title('');
set(s,'XLim',[-300,0],'YLim',[-60,60],'XColor',[0,0,0],'YColor',[0,0,0],'XGrid','off','YGrid','off','GridLineStyle','--','YTick',[-60 -40 -20 0 20 40 60]);
set(s.XLabel,'FontSize',12,'FontName','TimesNewRoman');
set(s.YLabel,'FontSize',12,'FontName','TimesNewRoman');
linewidth=1.5;
set(s.Children(1).Children(1),'LineWidth',linewidth,'Color','#E5AD00');
set(s.Children(1).Children(2),'LineWidth',linewidth,'Color','#7C6FAF');
set(s.Children(2).Children(2),'LineWidth',linewidth,'Color','#AA7816');
set(s.Children(3).Children(2),'LineWidth',linewidth,'Color','#EE6C1B');
set(s.Children(4).Children(2),'LineWidth',linewidth,'Color','#E02F12');
set(s.Children(5).Children(2),'LineWidth',linewidth,'Color','#75AB43');
set(s.Children(6).Children(2),'LineWidth',linewidth,'Color','#238392');
set(s.Children(7).Children(2),'LineWidth',linewidth,'Color','#0728E4');
grid on;
legend('r=3.5','r=2.5','r=1.8','r=1.4','r=1.3','r=1.2','r=0.9');
回答(1 个)
Voss
2024-7-23
编辑:Voss
2024-7-23
w0=300;
l1=2*w0;
l2=w0^2;
k=60;
s=tf('s');
r=[0.9,1.2,1.3,1.4,1.8,2.5,3.5];
H=figure;
for i=1:numel(r)
transfer_function=k*(s^2+l1*s+l2)/(r(i)*s^3+r(i)*(l1+k)*s^2+(k*l1+l2)*s+k*l2);
pzmap(transfer_function)
hold on;
end
s=findobj(gcf,'Type','Axes');
title(s,'');
set(s,'XLim',[-300,0],'YLim',[-60,60],'XColor',[0,0,0],'YColor',[0,0,0],'GridLineStyle','--','YTick',[-60 -40 -20 0 20 40 60]);
set(s.XLabel,'FontSize',12,'FontName','TimesNewRoman');
set(s.YLabel,'FontSize',12,'FontName','TimesNewRoman');
grid(s,'on');
delete(findall(s,'Type','text'))
h = [s.Children(1).Children(1); arrayfun(@(x)x.Children(2),s.Children(1:numel(r)))];
linewidth=1.5;
set(h,'LineWidth',linewidth,{'Color'},{'#E5AD00';'#7C6FAF';'#AA7816';'#EE6C1B';'#E02F12';'#75AB43';'#238392';'#0728E4'})
legend(h(end:-1:2),"r="+r,'Location','northwest');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Stability Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!