(FOR STEP RESPONSE GRAPHICS) how to make an inset of matlab figure inside the figure

2 views (last 30 days)
Dorukhan Astekin
Dorukhan Astekin on 30 Dec 2020
Edited: Mischa Kim on 30 Dec 2020
I have a code like below. How can I get another figure in the figure for the step response when I run this code? Please help me.
s=tf('s');
kp11=0.1517;
ki11=0.0325;
kp1=0.3786;
kd1=0.2694;
C1=kp11+ki11/s;
C2=kp1+kd1*s;
G=(4/(4*s-1))*exp(-2*s);
H1=feedback(G,C2);
H2=feedback(H1*C1,1);
step(H2,'r')
hold on
grid on
xlim([0 100])
ylim([0 1.2])
S=stepinfo(H2)
hold on;
s=tf('s');
kp22=0.1608;
ki22=0.0412;
kp2=0.3904;
kd2=0.3593;
C3=kp22+ki22/s;
C4=kp2+kd2*s;
G=(4/(4*s-1))*exp(-2*s);
H3=feedback(G,C4);
H4=feedback(H3*C3,1);
step(H4,'b')
hold on
grid on
S=stepinfo(H4)
hold on;
s=tf('s');
kp33=0.1387;
ki33=0.0443;
kp3=0.4181;
kd3=0.3873;
C5=kp33+ki33/s;
C6=kp3+kd3*s;
G=(4/(4*s-1))*exp(-2*s);
H5=feedback(G,C6);
H6=feedback(H5*C5,1);
step(H6,'g')
hold on
grid on
S=stepinfo(H6)
hold on;
s=tf('s');
kp44=0.1071;
ki44=0.0394;
kp4=0.4403;
kd4=0.3416;
C7=kp44+ki44/s;
C8=kp4+kd4*s;
G=(4/(4*s-1))*exp(-2*s);
H7=feedback(G,C8);
H8=feedback(H7*C7,1);
step(H8,'m')
hold on
grid on
S=stepinfo(H8)
hold on;
s=tf('s');
kp55=0.0434;
ki55=0.0272;
kp5=0.4695;
kd5=0.2041;
C9=kp55+ki55/s;
C10=kp5+kd5*s;
G=(4/(4*s-1))*exp(-2*s);
H9=feedback(G,C10);
H10=feedback(H9*C9,1);
step(H10,'c')
hold on
grid on
S=stepinfo(H10)

Answers (1)

Mischa Kim
Mischa Kim on 30 Dec 2020
Edited: Mischa Kim on 30 Dec 2020
Hi Dorukhan,
add another axes() to the bottom of your code. E.g.
p = get(gca, 'Position');
h = axes('Parent', gcf, 'Position', [p(1)+0.1 p(2)+0.1 p(3)-0.5 p(4)-0.5]);
x = 0:0.1:2;
y = cos(x);
plot(h, x, y, 'r');
and adjust the plot as necessary.

Community Treasure Hunt

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

Start Hunting!