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

조회 수: 3 (최근 30일)
Sicong Wen
Sicong Wen 2024년 7월 23일
댓글: Walter Roberson 2024년 7월 23일
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
Walter Roberson
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
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');

카테고리

Help CenterFile Exchange에서 Stability Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by