0% found this document useful (0 votes)
39 views8 pages

2.1 A) X 0:0.1: (4 Pi) y Sin (X) ./ (1+cos (X) ) Plot (X, Y) Xlabel ('X') Ylabel ('Y')

This document contains MATLAB code for plotting various functions. It includes: 1) Plotting sin(x)/(1+cos(x)), 1/(1+(x-2)^2), and exp(-x)x^2. 2) Plotting two piecewise functions on the same axes and separately with different line styles. 3) Plotting sin(-t)+t vs 1-cos(-t). 4) Additional plots including mesh and contour plots. 5) Code for plotting a smiling face with nose and hair.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views8 pages

2.1 A) X 0:0.1: (4 Pi) y Sin (X) ./ (1+cos (X) ) Plot (X, Y) Xlabel ('X') Ylabel ('Y')

This document contains MATLAB code for plotting various functions. It includes: 1) Plotting sin(x)/(1+cos(x)), 1/(1+(x-2)^2), and exp(-x)x^2. 2) Plotting two piecewise functions on the same axes and separately with different line styles. 3) Plotting sin(-t)+t vs 1-cos(-t). 4) Additional plots including mesh and contour plots. 5) Code for plotting a smiling face with nose and hair.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

2.

1
a) >> x = 0:0.1:(4*pi);
>> y=sin(x)./(1+cos (x));
>> plot(x,y)
>> xlabel('x');ylabel('y')

2.1
b) >> y=1./(1+(x-2).^2);
>> x = 0:0.1:4;
>> y=1./(1+(x-2).^2);
>> plot(x,y)
>> xlabel('x');ylabel('y')

2.1
c) >> x = 0:0.1:10;
>> y=exp(-x).*x.^2;
>> plot(x,y)
>> xlabel('x');ylabel('y')

2.3
a)
>> x=0:0.1:6;
>> y1=((x-1).*(x-2).*(x-4).*(x-5))./((3-1).*(3-2).*(3-4).*(3-5));
>> y2=((x-2).*(x-3).*(x-4).*(x-5))./((1-2).*(1-3).*(1-4).*(1-5));
plot(x,y1,x,y2)

b)
>> x=0:0.1:6;
>> y1=((x-1).*(x-2).*(x-4).*(x-5))./((3-1).*(3-2).*(3-4).*(3-5));
>> plot(x,y1);
>> hold on
>> y2=((x-2).*(x-3).*(x-4).*(x-5))./((1-2).*(1-3).*(1-4).*(1-5));
>> plot(x,y2,'--')
>> xlabel('x');ylabel('y1(-),y2(--)')

2.6
>> t=0:0.1:(4*pi);
>> x=sin(-t)+t;
>> y=1-cos(-t);
>> plot(x,y)

2.8
>> x=(0:.01:4*pi)'; y=sin(x)./(1+cos(x));plot(x,y),grid,title('Funcion y(x)')
>> x=-3:0.01:3;
y=-3:0.01:3;
[x,y]=meshgrid(x,y);
z=0.2*cos(x)+y.*exp(-x.^2.-y.^2);
mesh(x,y,z)
xlabel ('x')
ylabel ('y')
zlabel ('z')
grid on
title ('Grafica de funcion con mesh'

2.12 Dibuje su propia carita feliz con nariz y cabello.


dt=pi/20
t=0:dt:2*pi;
x=cos(t);y=sin(t);
axis([-1 1 -1 1]), hold on
plot(x,y); %contorno de la cara
hold on
for k=0.8:-0.5:0.5

plot (k*0.1*x-0.3,k*0.15*y+0.1)
plot (k*0.1*x+0.3,k*0.15*y+0.1)
end
s1=3*pi/2-1.1;
s2=3*pi/2+1.1;
s=s1:dt:s2
xs=0.5*cos(s); ys=0.5*sin(s);
plot(xs,ys) %boca
hold off

%ojo izquierdo
%ojo derecho

You might also like