How do I combine multiple plots separately on one figure?

figure(1)
R1 = 6;
R2 = 2.5;
R3 = 2;
time = 0:0.01*pi:10*pi;
axis([-9, 9, -9, 9]);
hold on
for j = 1:length(time)
t = time(j);
x = (R1-R2)*cos(t) + R3*cos(t*((R2-R1)/R2));
y = (R1-R2)*sin(t) + R3*sin(t*((R2-R1)/R2));
r = (1.2*R1-R2)*cos(t) + R3*cos(t*((R2-R1)/R2));
n = (1.2*R1-R2)*sin(t) + R3*sin(t*((R2-R1)/R2));
q = (1.1*R1-R2)*cos(t) + R3*cos(t*((R2-R1)/2*R2));
e = (1.1*R1-R2)*sin(t) + R3*sin(t*((R2-R1)/2*R2));
i = (1.3*R1-R2)*cos(t) + 1.5*R3*cos(t*((1.2*R2-R1)/2*R2));
w = (1.3*R1-R2)*sin(t) + 1.5*R3*sin(t*((1.2*R2-R1)/2*R2));
p(j) = plot( x, y, 'bx', 'MarkerSize', 10);
set(p(j), 'Color', [0, 0, 0.255])
p(j) = plot( r, n, 'bo', 'MarkerSize', 10);
set(p(j), 'Color', [rand, rand, rand])
p(j) = plot( q, e, 'bx', 'MarkerSize', 10);
set(p(j), 'Color', [rand, rand, rand])
p(j) = plot( i, w, 'bx', 'MarkerSize', 10);
set(p(j), 'Color', [0.1, 0.1, 0.1])
pause(0.0001);
end

 Accepted Answer

The two options are subplot and stackedplot. I use subplot here —
figure(1)
R1 = 6;
R2 = 2.5;
R3 = 2;
time = 0:0.01*pi:10*pi;
axis([-9, 9, -9, 9]);
t = time;
x = (R1-R2)*cos(t) + R3*cos(t*((R2-R1)/R2));
y = (R1-R2)*sin(t) + R3*sin(t*((R2-R1)/R2));
r = (1.2*R1-R2)*cos(t) + R3*cos(t*((R2-R1)/R2));
n = (1.2*R1-R2)*sin(t) + R3*sin(t*((R2-R1)/R2));
q = (1.1*R1-R2)*cos(t) + R3*cos(t*((R2-R1)/2*R2));
e = (1.1*R1-R2)*sin(t) + R3*sin(t*((R2-R1)/2*R2));
i = (1.3*R1-R2)*cos(t) + 1.5*R3*cos(t*((1.2*R2-R1)/2*R2));
w = (1.3*R1-R2)*sin(t) + 1.5*R3*sin(t*((1.2*R2-R1)/2*R2));
subplot(2,2,1)
plot( x, y, 'bx', 'MarkerSize', 10)
axis('square')
axis([-9, 9, -9, 9])
subplot(2,2,2)
plot( r, n, 'bo', 'MarkerSize', 10)
axis('square')
axis([-9, 9, -9, 9])
subplot(2,2,3)
plot( q, e, 'bx', 'MarkerSize', 10)
axis('square')
axis([-9, 9, -9, 9])
subplot(2,2,4)
plot( i, w, 'bx', 'MarkerSize', 10)
axis('square')
axis([-9, 9, -9, 9])
.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Release

R2021b

Tags

Asked:

on 5 Nov 2021

Edited:

on 5 Nov 2021

Community Treasure Hunt

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

Start Hunting!