EXPERIMENT

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

EXPERIMENT-1

I. Compute the following arithmetic operations.

a) Solve r = (π)1/3
-1 and then compute A=2πrh with h=9.

Solution:
>> r=pi^(1/3)-1
r = 0.4646
>> h=9;
>> A=2*pi*r*h
A = 26.2721

b) Solve log e3

Solution:
>> log (exp(3))
ans = 3
c) Solve log10e3

Solution:
>>log10(exp(3))
ans = 1.3029

d) Solve log(e(3^2)-1)

Solution:
>> log (exp(3^2)-1)
ans = 8.99993

e) Solve sin()+ cos()


Solution:
>> (//sin(pi/6))^2 + (cos(pi/6))^2
ans = 1
f) Solve 𝑒
𝜋
2
𝑖

Solution:
>>exp((pi/2)*i)
ans = 0.0000 + 1.0000i

g) Solve log(e(3^2-1))

>>log(exp(3^2-1))
ans = 8
EXPERIMENT-2

To generate 2D & 3D plots using script and function files.


a. Plot y= sin x. where x is ranging from0 to 2𝝅, take 100 linearly space points in
given interval.

x=linspace(0,2*pi);
y=sin(x); plot(x,y)
xlabel('x')
ylabel('y')
title('This graph is created by 2104416')

b. Plot y = e-0.4*sin x. Where, x is from 0 to 4π taking 10,50,100 points in the


interval.

x=linspace(0,4*pi*10); y=exp(-
0.4*x).*sin(x); subplot(3,1,1) plot(x,y)
xlabel('x') ylabel('y') title('This graph is
created by 2104394')
x=linspace(0,4*pi,50); y=exp(-
0.4*x).*sin(x); subplot(3,1,2) plot(x,y)
xlabel('x') ylabel('y') title('This graph is
created by 2104394')
x=linspace(0,4*pi); y=exp(-
0.4*x).*sin(x); subplot(3,1,3) plot(x,y)
xlabel('x') ylabel('y') title('This graph is
created by 2104416')

Output :

C. Plot y = cosx and z = 1-x2/2+x4/24, where x lies between 0 to π.

x=linspace(0,pi); y=cos(x); z=1-(x.^2/2)+


(x.^4/24); plot(x,y,x,z,'--')
legend('y=cos(x)','z=1-(x.^2/2)+(x.^4/24)')
xlabel('x')
ylabel('y')
title ('This graph is created by 2104416 ')
d. Write a script files to draw a unit circle.

theta=linspace(0,2*pi,50);
x=cos(theta);
y=sin(theta); plot(x,y)
axis('equal') xlabel('x')
ylabel('y')
title('This graph is created by 2104416')

Output :
EXPERIMENT-3

To create MATLAB code for the generation of unit step, unit impulse, exponential and
ramp signal in continuous and discrete domain.

Clear all;

%CONTINUOUS UNIT STEP FUNCTION


t=linspace(-5,5,100)
x=(t>=0);
subplot(5,2,1)
plot(t,x) xlabel('t')
ylabel('x(t)')
title('continuous unit step signal created by Roll no.2104416')

%DISCRETE UNIT STEP FUNCTION


n=-5:5 x=(n>=0); subplot(5,2,2) plot(n,x)
xlabel('t') ylabel('x(t)')
title('discrete unit step signal created by Roll no. 2104416')

%CONTINUOUS UNIT IMPULSE FUNCTION


t=(-1:0.01:1) x=(t==0); subplot(5,2,3) plot(t,x)
xlabel('t') ylabel('x(t)')
title('continuous unit impulse signal created by Roll no. 2104416')

%DISCRETE UNIT IMPULSE FUNCTION


n=-5:5 x=(n==0); subplot(5,2,4) plot(n,x)
xlabel('n') ylabel('x(n)')
title('discrete unit impulse signal created by Roll no. 2104416')

%CONTINUOUS EXPONENTIAL RISING SIGNAL FUNCTION


t=linspace(-5,5,100) x=exp(t); subplot(5,2,5) plot(t,x)
xlabel('t') ylabel('x=exp(t)')
title('continuous exponential rising signal created by Roll no. 2104416')

%CONTINUOUS EXPONENTIAL DECAYING SIGNAL FUNCTION


t=linspace(-5,5,100) x=exp(-t); subplot(5,2,6) plot(t,x) xlabel('t')
ylabel('x=exp(-t)')
title('continuous exponential decaying signal created by Roll no. 2104416')

%DISCRETE EXPONENTIAL RISING SIGNAL FUNCTION


n=-10:10; a=1.5; x=a.^n; subplot(5,2,7) plot(n,x) xlabel('n')
ylabel('x(n)')
title('discrete exponential signal created by Roll no. 2104416')

%CONTINUOUS UNIT RAMP SIGNAL FUNCTION


t=linspace(-5,5,100)
x=t.*(t>=0);
subplot(5,2,8)
plot(t,x) xlabel('t')
ylabel('x(t)')
title('continuous unit ramp signal created by Roll no. 2104416')

%DISCRETE UNIT RAMP SIGNAL FUNCTION


n=-10:10; x=n.*(n>=0); subplot(5,2,9) plot(n,x)
xlabel('n') ylabel('x(n)')
title('discrete unit ramp signal created by Roll no. 2104416')

Output :
EXPERIMENT-4

To create MATLAB code for performing operations on continuous time signals like:
addition, multiplication, shifting and scaling.

t=linspace(-10,10);
x1=(t>=0); x2=(t>=-2);

%Adition Of Two Signals


x=x1+x2; subplot(4,1,1)
plot(t,x) xlabel('t')
ylabel('x')
title('Addition Of Two Signals by 2104416')

%Multiplication Of Two Signals


y=x1.*x2; subplot(4,1,2) plot(t,y)
xlabel('t') ylabel('y')
title('Multiplication Of Two Signals by 2104416')

%Shifting Of One Signal


z=x1+2; subplot(4,1,3)
plot(t,z) xlabel('t')
ylabel('z')
title('Shifting OF One Signals by 2104416')

%Shifting And Scaling Of Two Signals


r=2*x1+2; subplot(4,1,4) plot(t,z)
xlabel('t') ylabel('r')
title('Shifting And Scaling Of Two Signals by 2104416')
Output :

EXPERIMENT-5

To compute fourier transform and inverse fourier transform of a signal in MATLAB.

syms t x; s=exp(-t^2-
x^2); f=fourier(s)
y=ifourier(f)

Output :
>> exp4
f=
pi^(1/2)*exp(- t^2 - w^2/4)
y=
exp(- t^2 - x^2)
EXPERIMENT-6

To compute convolution and co-relation between continuous time signal.

%Convolution of two signal.


t=linspace(0,2*pi);
x=cos(t); y=sin(t);
z=conv(x,y)
t1=0:length(z)-1
subplot(1,2,1)
plot(t1,z)
xlabel('t1')
ylabel('z')
title('convolution of two signal is plotted by 2104416')

%Co-relation of two signal.


t=linspace(0,2*pi);
x=cos(t); y=sin(t);
s=xcorr(x,y)
t2=0:length(s)-1
subplot(1,2,2)
plot(t2,s)
xlabel('t2')
ylabel('s')
title('co-relation of two signal is plotted by 2104416')

Output :

You might also like