GENERATION OF UNIT STEP SEQUENCE
clear all; clc; close all
%generate unit step sequence for N=20.
N=20;
xn=[ones(1,N) zeros(1,N)];
n=0:1:N*2-1;
subplot(2,1,1),stem(n,xn);
subplot(2,1,2),plot(n,xn);
xlabel('n');
ylabel('xn');
title('Unit Step Sequence');
GENERATION OF EXPONENTIALLY INCREASING AND DECREASING SIGNALS
clear all; clc; close all
% Plot an exponential sequence (0.7)^n
N=30;
n=0:N-1;
e=exp(j*pi);
a=0.7*e;
xn=a.^n;
subplot(2,2,1),stem(n,xn);
subplot(2,2,2),plot(n,xn);
xlabel('n');
ylabel('xn');
title('Exponential Decreasing Sequence');
a=-0.7*e;
xn=a.^n;
xn=a.^n;
subplot(2,2,3),stem(n,xn);
subplot(2,2,4),plot(n,xn);
xlabel('n');
ylabel('xn');
title('Exponential Decreasing Sequence');
figure
a=1.7*e;
xn=a.^n;
xn=a.^n;
subplot(2,2,1),stem(n,xn);
subplot(2,2,2),plot(n,xn);
xlabel('n');
ylabel('xn');
title('Exponential Increasing Sequence');
a=-1.7*e;
xn=a.^n;
xn=a.^n;
subplot(2,2,3),stem(n,xn);
subplot(2,2,4),plot(n,xn);
xlabel('n');
ylabel('xn');
title('Exponential Increasing Sequence');
GENERATION OF COSINE AND SINE WAVES OF 100HZ WITH 2KHZ SAMPLING
clear all; clc; close all
% Plot an sinusoidal sequence
fs=2000;%Sampling freq of 2KHz
n=0:1/fs:1;
xn=cos(2*pi*100*n);
subplot(2,2,1),stem(n(1:50),xn(1:50));
subplot(2,2,2),plot(n(1:50),xn(1:50));
xlabel('n');
ylabel('xn');
title('Sinusoidal Sequence');
xn=sin(2*pi*100*n);
subplot(2,2,3),stem(n(1:50),xn(1:50));
subplot(2,2,4),plot(n(1:50),xn(1:50));
xlabel('n');
ylabel('xn');
title('Sinusoidal Sequence');
PLOTTING OF TRAINGULAR, SAWTOOTH AND SQUARE WAVES WITHOUT USING MATLAB IN BULIT COMMANDS TO GET ACCUSTOMED TO PLOT FEATURES AND FOR LOOP TECHNIQUES
clear all; clc; close all
%TRAINGUALAR WAVE PLOT
y=0:0.5:2;
for j=0:3
x=(4*j)+y;
plot(x,y)
hold on
end
for k=0:3;
x=(4*k)-y
plot(x,y)
hold on
end
hold off
%SAWTOOTH WAVE PLOT
figure
y=0:.5:2
for j=0:8
a=(2*j)+y
plot(a,y,'b')
hold on
end
x=2:2:18
for k=0:.01:2;
b=k;
plot(x,b,'b')
hold on
end
hold off
%SQUARE WAVE PLOT
figure
y=0:.001:2;
for j=0:2:12;
x=y;
plot(j,x,'r');
hold on;
end
for k=0:4:12;
x=k+y;
m=2;
plot(x,m,'r')
hold on
end
for k=2:4:12;
x=k+y;
m=0;
plot(x,m,'r');
hold on;
end
hold off
axis([0 12 -0.5 2.5])
GENERATION OF DIFFERENT SINOSOIDAL SIGNALS TO SHOW ALISING EFFECT IN DSP
clear all; clc; close all
% Plot an sinusoidal sequence and compare aliasing
fs=2000;%Sampling freq of 2KHz can work for frequencies upto 1KHz only
n=0:1/fs:1;
f1=100; % f1=100Hz
f2=300; % f2=300Hz
xn1=cos(2*pi*f1*n);
xn2=cos(2*pi*f2*n);
xn=xn1+xn2;
subplot(2,2,1),stem(n(1:50),xn(1:50));
subplot(2,2,2),plot(n(1:50),xn(1:50),'b', n(1:50),xn1(1:50),'g', n(1:50),xn2(1:50),'r');
xlabel('n');
ylabel('xn');
title('Sinusoidal Sequence');
f1a=2000-100; % f2=1900Hz
f2a=2000-300; % f2=1700Hz
xn1a=cos(2*pi*f1a*n);
xn2a=cos(2*pi*f2a*n);
xna=xn1a+xn2a;
subplot(2,2,3),stem(n(1:50),xna(1:50));
subplot(2,2,4),plot(n(1:50),xna(1:50),'b', n(1:50),xn1a(1:50),'g', n(1:50),xn2a(1:50),'r');
xlabel('n');
ylabel('xn');
title('Sinusoidal Sequence');
figure
fre1=300; % fre1=300Hz
a1=cos(2*pi*fre1*n);
fre2=2000-300; % fre2=1700Hz
a2=cos(2*pi*fre2*n);
fre3=2000+300; % fre1=2300Hz
a3=cos(2*pi*fre3*n);
subplot(3,1,1),stem(n(1:50),a1(1:50));
subplot(3,1,2),stem(n(1:50),a2(1:50));
subplot(3,1,3),stem(n(1:50),a3(1:50));
No comments:
Post a Comment