0% found this document useful (0 votes)
46 views4 pages

Sinc Function Lab#02 Task1

This document contains code for plotting various mathematical functions using MATLAB. It includes: 1) Plotting the sinc function sin(x)/x and cosine function cos(2*pi*f*x) 2) Plotting the logarithm and square root functions on the same graph with different styles 3) Using subplot to display the sine, cosine and tangent functions on the same figure 4) Plotting 3D data and generating a surface plot of sin(r)/r

Uploaded by

Komal Ejaz
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)
46 views4 pages

Sinc Function Lab#02 Task1

This document contains code for plotting various mathematical functions using MATLAB. It includes: 1) Plotting the sinc function sin(x)/x and cosine function cos(2*pi*f*x) 2) Plotting the logarithm and square root functions on the same graph with different styles 3) Using subplot to display the sine, cosine and tangent functions on the same figure 4) Plotting 3D data and generating a surface plot of sin(r)/r

Uploaded by

Komal Ejaz
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/ 4

Sinc function

Lab#02 task1

x=-20:0.01:20
y=sin(x)./x
plot(x,y)
xlabel('x')
ylabel('sin(x)/x')

cosine function

x=-20:0.01:20
f=0.3
y=cos(2*pi*f*x)
plot(x,y)
xlabel('x')
ylabel('cos(2*pi*f*x)')

sine function

x=-20:0.01:20
f=0.3
y=sin(2*pi*f*x)
plot(x,y,'-')
xlabel('x')
ylabel('sin(2*pi*f*x)')

Task 2

x=1:100;
y=log(x)
z=sqrt(x)
plot(x,y,'r')

hold on
plot(x,z,'g')
xlabel('time')
ylabel('amplitude')
hold off
for texture
plot(x,y,'r+')

plot(x,z,'g*')
task 3

Subploting command

x=linspace (0,2*pi,50)
y=sin(x)
z=cos(x)
w=tan(x)
subplot 221
plot(x,y)
subplot 222
plot(x,z)
subplot 223
plot(x,w)

data = [ 5.1000 3.5000 1.4000


4.9000 3.0000 1.4000
4.7000 3.2000 1.3000
4.6000 3.6000 1.5000
5.0000 3.9000 1.4000
5.4000 3.4000 1.7000
4.6000 3.4000 1.4000
5.0000 3.4000 1.5000]
plot3(data(:,1),data(:,2),data(:,3))
[x,y]=meshgrid(-8:0.5:8)
r=sqrt(x.^2+y.^2)+eps
z=sin(r)./r
surf(x,y,z)

You might also like