Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Smiling sun in MATLAB


Code:

clc
clear all
close all
fill([-3 -3 3 3],[-3 3 3 -3],'k');
axis([-3 3 -3 3]);
hold on;
pause(1);
%body
t=0:0.01:2*pi;
x=cos(t);
y=sin(t);
fill(x,y,'y');
axis square;
axis([-3 3 -3 3]);
hold on;
pause(1);
%mouth
t=pi:0.01:2*pi;
x=0.5*cos(t);
y=-0.2+0.5*sin(t);
patch(x,y,[1 0.5 0]);
pause(1);
%left eye
t=0:0.01:pi;
x=-0.5+0.25*cos(t);
y=0.5*sin(t);
plot(x,y,'color',[1 0.5 0],'linewidth',4);
pause(1);
%right eye
t=0:0.01:pi;
x=0.5+0.25*cos(t);
y=0.5*sin(t);
plot(x,y,'color',[1 0.5 0],'linewidth',4);
pause(1);
%vertical ray
t=0:pi/2:2*pi;
x1=2*cos(t);
y1=2*sin(t);
x2=1.2*cos(t);
y2=1.2*sin(t);
for i=1:length(t)
    plot([x1(i) x2(i)],[y1(i) y2(i)],'y','linewidth',3);
    pause(0.5);
end
%angled ray
t=pi/4:pi/2:2*pi+pi/4;
x1=1.7*cos(t);
y1=1.7*sin(t);
x2=1.2*cos(t);
y2=1.2*sin(t);
for i=1:length(t)
    plot([x1(i) x2(i)],[y1(i) y2(i)],'y','linewidth',3);
    pause(0.5);
end


No comments

Popular Posts