Write MATLAB code for display and plot a) unit Step, b) Rectangular, c) standard
triangle d) sinusoidal and e) Exponential signal.
N=100
u=ones(1,N)
t1=0:1:N-1
subplot(6,1,1)
plot(t1,u)
xlabel('time')
ylabel('amplitude')
title('Unit step function')
subplot(6,1,2)
stem(t1,u)
xlabel('discreate value')
ylabel('amplitude')
title('Unit step discreate function')
%Rectangular
t2=-10:0.02:10
rect=rectpuls(t2,4)
subplot(6,1,3)
plot(t2,rect)
xlabel('sequence')
ylabel('amplitude')
title('rectangular pulses')
%standard triangle
t3=-10:0.02:10
tri=triang(length(t3))
subplot(6,1,4)
plot(t3,tri)
xlabel('sequence')
ylabel('amplitude')
title('Triangular pulses')
%sinusoidal
f=5
t4=0:0.01:10
x=sin(2*pi*f*t4)
subplot(6,1,5)
plot(t4,x)
xlabel('sequence')
ylabel('amplitude')
title('sine wave')
%Expontential signal
t5=0:0.01:10
a=0.5
expn=exp(a*t5)
subplot(6,1,6)
plot(t5,expn)
xlabel('sequence')
ylabel('amplitude')
title('exponential')
Write MATLAB code for display and plot time and frequency domains for a
rectangular pulse.
a=input('enter the width of the pulse=')
t=-2:0.1:2
x=rectpuls(t,a)
subplot(3,1,1)
plot(t,x)
axis=([-2 2 0 2])
xlabel('time')
ylabel('amplitude')
title('time domain representation')
X=fft(x)
subplot(3,1,2)
plot(t,abs(X))
xlabel('time')
ylabel('amplitude')
title('frequency domain')
subplot(3,1,3)
plot(t,fftshift(abs(X)))
xlabel('time')
ylabel('amplitude')
title('time domain representation')
Write MATLAB code for generate and plot Amplitude Modulation and
demodulation signals and its spectrums.
fs=8000;
t=(0:1/fs:0.5);
fc=300;
fm=10;
Vm=14;
Vc=7;
vm=Vm*sin(2*pi*fm*t);
vam=ammod(vm,fc,fs);
subplot(2,1,1)
plot(t,vam)
xlabel('Time')
ylabel('Amplitude')
title('Modulated Signal')
demod=amdemod(vam,fc,fs);
subplot(2,1,2)
plot(t,demod)
xlabel('Time')
ylabel('Amplitude')
title('Demodulated Signal')
Write MATLAB code for generate and plot Frequency Modulation and
demodulation signals and its spectrums
fs=1000;
fc=100;
fm=5;
t=0:0.001:0.5;
Vm=1
Vc=1
fd=50;
vm=Vm*sin(2*pi*fm*t)
vc=Vc*sin(2*pi*fc*t)
vfm=fmmod(vm,fc,fs,fd)
d=fmdemod(vfm,fc,fs,fd)
subplot(4,1,1)
plot(t,vm)
xlabel('time')
ylabel('amplitude')
title('message signal')
subplot(4,1,2)
plot(t,vc)
xlabel('time')
ylabel('amplitude')
title('carrier signal')
subplot(4,1,3)
plot(t,vfm)
xlabel('time')
ylabel('amplitude')
title('modulated signal')
subplot(4,1,4)
plot(t,d)
xlabel('time')
ylabel('amplitude')
title('demodulated signal')
Write MATLAB code for display and plot Sampling and reconstruction of low
pass signals.
clc
fc=20
fs=500
T=1/fs
t=0:T:1-T
fm=20
x=sin(2*pi*fm*t)
subplot(3,2,1)
plot(t,x)
xlabel('time')
ylabel('amplitude')
title('low pass signal')
X=fft(x)/length(x)
f=linspace(0,fs,length(x))
subplot(3,2,2)
plot(f,20*log10(abs(X)))
xlim([0 fs/2])
xlabel('frequency')
ylabel('magnitude')
title('frequency spectrum of input signal')
n=0:T:1-T
x2=sin(2*pi*fm*n)
subplot(3,2,3)
stem(n,x2)
xlabel('samples')
ylabel('amplitude')
title('sampled signals')
X2=fft(x2)/length(x2)
f=linspace(0,fs,length(x2))
subplot(3,2,4)
plot(f,20*log10(abs(X2)))
xlim([0 fs/2])
xlabel('frequency')
ylabel('magnitude')
title('frequency spectrum of sampled signal')
wn=fc/(fs/2)
b=fir1(30,wn)
x3=filter(b,1,x2)
subplot(3,2,5)
plot(t,x3)
xlabel('time')
ylabel('amplitude')
title('reconstructed signals')
X3=fft(x3)/length(x3)
f=linspace(0,fs,length(x3))
subplot(3,2,6)
plot(f,20*log10(abs(X3)))
xlim([0 fs/2])
xlabel('frequency')
ylabel('magnitude')
title('frequency spectrum of reconstructed signal')
Generate a) Raised cosine pulse,
Ts=0.01;
N=2000;
t=-20:Ts:(N-1)*Ts;
R_cos1=(sin(pi*t.*(1-0))+4*0*t.*cos(pi*t.*(1+0)))./(pi*t.*(1-(4*0*t).^2));
subplot(1,3,1)
plot(R_cos1)
R_cos2=(sin(pi*t.*(1-0.5))+4*0.5*t.*cos(pi*t.*(1+0.5)))./(pi*t.*(1-(4*0.5*t).^2));
subplot(1,3,2)
plot(R_cos2,'r')
R_cos3=(sin(pi*t.*(1-1))+4*1*t.*cos(pi*t.*(1+1)))./(pi*t.*(1-(4*1*t).^2));
subplot(1,3,3)
plot(R_cos3,'b')
b) Generate and plot eye diagram
samples_per_symbol=10
data_length=1000
data=randi([0,1],1,data_length)
num_Symbols=data_length/samples_per_symbol
eye_data=reshape(data,samples_per_symbol,num_Symbols)
plot(eye_data)
xlabel('Sample')
ylabel('Amplitude')
title('Eye diagram')
grid on;
Generate the Probability density function of Gaussian distribution function.
mu=0
sigma=1
x=-5:0.1:5
pdf=normpdf(x,mu,sigma)
figure
plot(x,pdf,'Linewidth',3)
xlabel('x')
ylabel('pdf')
title('Pdf of Gaussian Distribution')
grid on
Display the signal and its spectrum of an audio signal .
Fs = 44100;
t = 0:1/Fs:1-1/Fs;
F = 1000;
audiosignal = sin(2*pi*F*t);
subplot(2,1,1);
plot(t, audiosignal);
xlabel('time');
ylabel('Amp');
title('Sine wave');
n = length(audiosignal);
Y = fft(audiosignal, n);
Y_0 = fftshift(Y);
F_0 = (0:n-1)*(Fs/n);
subplot(2,1,2);
plot(F_0, abs(Y_0));