Triangles inside triangles using MATLAB

MATLAB Program:

%Code:
%https://www.matlabcoding.com/

clc
clear all
close all
figure;
pause(3);
axis square;
t=0:2*pi/3:2*pi;
x=5*cos(t);
y=5*sin(t);
pause(1);
axis square;
hold on;
for i=1:11
m=(x(1)+x(2))/2;
n=(x(2)+x(3))/2;
o=(x(3)+x(4))/2;
p=(y(1)+y(2))/2;
q=(y(2)+y(3))/2;
r=(y(3)+y(4))/2;
plot([m n o m],[p q r p]);
hold on;
pause(1);
axis square;
x=[m n o m];
y=[p q r p];
end



No comments