x = linspace(-4*pi, 4*pi, 100);
y = sin(x);
plot (x, y,':om');
plot(x,y,'-o',...
'LineWidth',1,...
'MarkerSize',2,...
'MarkerEdgeColor','c',...
'MarkerFaceColor',[0.5,0.5,0.5])
plot(x,y,'Color',[0.5,0.1,0.7])
x = linspace(-4*pi, 4*pi, 100);
plot (x, sin (x));
xlabel('x-axis')
ylabel('y-axis')
title('Sine function')
axis([-12, 12, -1.5, 1.5])
clear all
x = linspace(-4*pi, 4*pi, 100);
plot (x, sin (x),'rs-');
xlabel('x-axis')
ylabel('y-axis')
title('Sine function')
axis([-12, 12, -1.5, 1.5])
clear all
figure(2)
x = linspace(-3, 3, 100);
y1 = x;
y2 = x.^3;
y3 = x.^5;
plot(x, y1, 'r')
hold on
plot(x, y2, 'g')
hold on
plot(x, y3, 'b')
axis('equal')
xlabel('x-axis')
ylabel('y-axis')
title('Power Functions Plots')
axis([-3, 3, -3, 3])
legend('y = x','y = x^3','y = x^5')
hold off
clear all
x = linspace(-4*pi, 4*pi, 100);
y1 = sin(x);
y2 = cos(x);
y3 = exp(x);
y4 = cosh(x);
subplot(2,2,1)
plot(x, y1, 'r')
subplot(2,2,2)
plot(x, y2, 'g')
subplot(2,2,3)
plot(x, y3, 'b')
axis([-3, 3, -1, 20])
subplot(2,2,4)
plot(x, y4, 'k')
axis('equal')
axis([-3, 3, 0, 6])
clear all
tx = linspace (-8, 8, 41);
ty = tx;
[xx, yy] = meshgrid (tx, ty);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
tz = sin (r) ./ r;
mesh (tx, ty, tz);
surf(r)
contourf(xx,yy,r,5)
contour(xx,yy,r,5)
x = -4*pi:0.01:4*pi;
figure(1)
filename = 'gifmovie.gif';
for n = 1:0.1:10
y = sin(x/n);
plot(x,y)
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if n == 1;
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end
figure(1)
filename = 'surfmovie.gif';
tx = linspace (-8, 8, 41);
ty = tx;
[xx, yy] = meshgrid (tx, ty);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
for n = 1:0.5:20
tz = sin (r) ./ (n*r);
mesh (tx, ty, tz);
axis([-8 8 -8 8 -1 1])
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if n == 1;
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end