How to remove the number caused by 'grid on' and How to change the legend mark

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');
Error using matlab.graphics.primitive.Line/set
Error setting property 'Color' of class 'Line':
Invalid color name or hexadecimal color code. Valid names include: 'red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'black', 'white', and 'none'. Valid hexadecimal color codes consist of '#' followed by three or six hexadecimal digits.
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 件のコメント

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');

サインインしてコメントする。

回答 (2 件)

Voss
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');
The pzplot chart API makes tasks like this much simpler.
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];
systems = cell(1,7);
colors = ["#E5AD00","#7C6FAF","#AA7816","#EE6C1B","#E02F12","#75AB43","#238392"];
h = pzplot();
h.NextPlot = "add";
for ii=1:7
sys=k*(s^2+l1*s+l2)/(r(ii)*s^3+r(ii)*(l1+k)*s^2+(k*l1+l2)*s+k*l2);
pzplot(sys,LineWidth=1.5,Color=colors(ii),Name="r="+r(ii));
end
h.Title.Visible = "off";
h.XLimits = [-300 0];
h.YLimits = [-60 60];
h.AxesStyle.GridVisible = "on";
h.AxesStyle.GridLineStyle = "--";
h.XLabel.FontSize = 12;
h.XLabel.FontName = "TimesNewRoman";
h.YLabel.FontSize = 12;
h.YLabel.FontName = "TimesNewRoman";
h.Legend.Visible = "on";
h.Legend.Location = "northwest";
I'll leave it to you to decide how best to add the arrows.

カテゴリ

質問済み:

2024 年 7 月 23 日

回答済み:

2026 年 6 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by