How to make a root locus plot square aspect ratio

I have tried:
s = tf('s');
sysL = (s^2+1)/(s*(s^2+4));
rlocus(sysL);
v=[-4 4 -4 4];
axis(v);
axis('square');
But I get a message that says: Warning: This plot type does not support this option for the "axis" command.
I am using 2013b

 채택된 답변

Star Strider
Star Strider 2015년 10월 7일
편집: Star Strider 2015년 10월 7일
It does not support axis('square'). It does support axis('equal'), but that overrides your axis(v) call.
You can override the aspect ratio with the 'Position' figure property:
s = tf('s');
sysL = (s^2+1)/(s*(s^2+4));
rlocus(sysL);
v=[-4 4 -4 4]; axis(v);
hpos = get(gcf, 'Position'); % Get 'Position'
set(gcf, 'Position',[hpos([1 2 4]) hpos(4)]) % Set Width = Height
Experiment to get the result you want.

댓글 수: 4

Daniel
Daniel 2015년 10월 7일
OK. That is better than what I started with.
However, is there any way to force a square aspect ratio? I don't really need the axis(v) since I did that just to try to force an equal axis length which axis('equal') already accomplishes.
My problem is that if the plot doesn't come up as a square or if I manually resize the plot, then the angles look all messed up.
Great. I modified your code a bit to re-capture what axis('equal') does, since I like that function and it saves me the step of trying to figure out what my axis limits should be.
s = tf('s');
sysL = (s^2+1)/(s*(s^2+4));
rlocus(sysL);
hpos = get(gcf, 'Position'); % Get 'Position'
set(gcf, 'Position',[hpos([1 2 4]) hpos(4)]) % Set Width = Height
axis('equal');
Is there any way to do this with the R2023b version?
@Ryszard Nowacki — I just now tested that same code here (R2023b), and it seems to work correctly.
Comparing them —
s = tf('s');
sysL = (s^2+1)/(s*(s^2+4));
figure
rlocus(sysL);
figure
rlocus(sysL);
hpos = get(gcf, 'Position'); % Get 'Position'
set(gcf, 'Position',[hpos([1 2 4]) hpos(4)]) % Set Width = Height
axis('equal');
It works as desired in R2023b.
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

질문:

2015년 10월 7일

댓글:

2023년 11월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by