Professional Documents
Culture Documents
Matlab
Matlab
Matlab
Index
S.No. Name of the Experiments Page No. Remarks
1 Matlab code for Generation of unit impulse
signal with delay and advance
2 Matlab code for Generation of unit step
signal with delay and advance
3 Matlab code for Generation of unit ramp •
signal with delay and advance
4 y=sin(t)
5 y=4*sin(t)^2
-2*pi<t<2*pi
6 y=4*sin(ωt)+cos(ωt)
-2*pi<t<2*pi
7 y=cos(t)
8 y=t==0
-2*pi<t<2*pi
9 y=4*cos(t)^2
-2*pi<t<2*pi
10 Step =t>=0
t=-1:0.109:1
11 y=t*ramp
ramp=t>=0
t=-1:0.1:1
12 When x(n)={1 ; n >= 0 , 0 ; n <0
3
Output:
02.Experiment Name:Matlab code for Generation of unit step signal with delay
and advance.
Matlab Code:
%Generation of unit step signal with delay and advance
clc;
clf;
clear all;
close all;
N=20;
n=-N:1:N;
subplot(3,1,1);
x=[zeros(1,N) 1 ones(1,N)];
stem(n,x);
grid;
title("Unit step signal");
xlabel("Discrete time ---N>>>");
ylabel("Amplitude");
subplot(3,1,2);
x=[zeros(1,N+5) 1 ones(1,N-5)];
7
stem(n,x);
grid;
title("Unit step delay signal");
xlabel("Discrete time ---N>>>");
ylabel("Amplitude");
subplot(3,1,3);
x=[zeros(1,N-5) 1 ones(1,N+5)];
stem(n,x);
grid;
title("Unit step advance signal");
xlabel("Discrete time ---N>>>");
ylabel("Amplitude");
Output:
03.Experiment Name:Matlab code for Generation of unit ramp signal with delay
and advance.
Matlab Code:
%Generation of unit ramp signal with delay and advance
clc;
clf;
8
clear all;
close all;
N=20;
n=-N:1:N;
subplot(3,1,1);
x=n.*(n>=0);
stem(n,x);
grid;
title("Unit ramp signal");
xlabel("Discrete time ---N>>>");
ylabel("Amplitude");
subplot(3,1,2);
x=n.*(n>=5);
stem(n,x);
grid;
title("Unit ramp delay signal");
xlabel("Discrete time ---N>>>");
ylabel("Amplitude");
subplot(3,1,3);
x=n.*(n>=-5);
stem(n,x);
grid;
title("Unit ramp advance signal");
xlabel("Discrete time ---N>>>");
ylabel("Amplitude");
Output:
9
04.Experiment Name:y=sin(t).
Matlab Code:
clc;
clf;
clear all;
close all;
t=-pi:(pi/16):pi;
y=sin(t);
plot(t,y);
hold on;
stem(t,y);
hold on;
plot(t,y);
grid;
title('sin wave');
xlabel('Continous time(t)');
ylabel('Amplitude')
Output:
10
Output:
11
Output:
12
07.Experiment Name:y=cos(t)
Matlab Code:
clc;
clf;
clear all;
close all;
t=-pi:(pi/5):2*pi;
y=cos(t);
plot(t,y);
hold on;
stem(t,y);
grid;
title('cosine Wave');
xlabel('Continous time(t)');
ylabel('Amplitude')
Output:
13
Output:
14
Output:
15
Output:
16
clc;
clf;
clear all;
close all;
t=-1:0.109:1;
ramp=t>=0;
y=t.*ramp;
plot(t,y);
hold on;
stem(t,y);
grid;
title('Unit ramp');
xlabel('Continuous time(t)');
ylabel('Amplitude');
Output:
17
Output:
18
Output:
19
Output:
20
clc;
clf;
clear all;
close all;
n=-20:20;
x=n.*(n>0);
stem(n,x);
title('Mid line');
Output:
21
Output:
22
clc;
clf;
clear all;
close all;
n=-20:20;
x=n.*((n+2)>0);
stem(n,x);
Output:
23
Output:
24
Output:
25
clc;
clf;
clear all;
close all;
n=-20:20;
N=40;
x=[zeros(1,(N/2+5)),1,zeros(1,(N/2-5))];
stem(n,x);
Output:
26
Output:
27
Output:
stem(n,x);
Output:
Output:
30
Output:
stem(n,x);
Output:
Output:
33
Output:
34
Output:
35
Output:
36
Output:
37
Output:
Output:
ylabel('Amplitude');
title('50 Hz sawtooth wave');
grid;
Output:
t=0:0.1:40;
x=exp(-0.1*t);
plot(t,x);
grid;
title("Exponential Signal");
xlabel("Time Index[ms]");
ylabel("Amplitude");
Output:
grid;
title("Unit ramp");
xlabel("t");
ylabel("r");
Output:
ylabel("Amplitude");
Output:
Output: