Question

In: Electrical Engineering

1. Open m file of sampandquant, uniquan and Prelab4 in MATLAB. a. Set the quantization levels...

1. Open m file of sampandquant, uniquan and Prelab4 in MATLAB.

a. Set the quantization levels of PCM (L) as 2 and 32. Compare your results.

b. Why did we choose the cut-off frequency of the ideal LPF as 30 Hz. What happens for small or very big values of the cut-off frequency?

c. Change the message signal as : xsig = cos(2pit) + cos(2pit)

d. First set the quantization levels of PCM (L) as 2 and 32. Compare your results. Then, set different values of L and compare your results.

e. What should be the cut off frequency of the ideal low pass filter for the signal given in part (c) so that the original and the recovered signals will look like each other?

Solutions

Expert Solution

Part A:

% (ExPCM.m)
% Example of sampling, quantization, and zero-order hold
clear all; close all; clc;
td=0.002; %original sampling rate 500 Hz
t=0:td:1.; % time interval of 1 second
xsig=sin(2*pi*t)-sin(6*pi*t); % 1Hz+3Hz sinusoids
Lsig=length(xsig);
Lfft=2^ceil(log2(Lsig)+1);
Xsig=fftshift(fft(xsig,Lfft));
Fmax=1/(2*td);
Faxis=linspace(-Fmax,Fmax,Lfft);
ts=0.02; % new sampling rate = 50 Hz
Nfact=ts/td;
% send the signal through a 16-level uniform quantizer
[s_out,sq_out,sqh_out1,Delta,SQNR]=sampandquant(xsig,2,td,ts);
% obtained the PCM signal which is
% - sampled, quantized, and zero-order hold signal sqh_out
% plot the orignal signal and the PCM signal in time domain
figure(1);
subplot(211);sfig1=plot(t,xsig,'k',t,sqh_out1(1:Lsig),'b');
set(sfig1,'Linewidth',2);
title('Signal {\it g}({\it t}) and its 2 level PCM signal');
xlabel('time (sec.)');
% send the signal throuhg a 4-level uniform quantizer
[s_out,sq_out,sqh_out2,Delta,SQNR]=sampandquant(xsig,32,td,ts);
% obtained the PCM signal which is
% - sampled, quantized, and zero-order hold signal sqh_out
% plot the orignal signal and the PCM signal in time domain
subplot(212);sfig2=plot(t,xsig,'k',t,sqh_out2(1:Lsig),'b');
set(sfig2,'Linewidth',2);
title('Signal {\it g}({\it t}) and its 32 level PCM signal');
xlabel('time (sec.)');

Lfft=2^ceil(log2(Lsig)+1);
Fmax=1/(2*td);
Faxis=linspace(-Fmax,Fmax,Lfft);
SQH1=fftshift(fft(sqh_out1,Lfft));
SQH2=fftshift(fft(sqh_out2,Lfft));
% Now use LPF to filter the two PCM signals
BW=10; %Bandwidth is no larger than 10Hz
H_lpf=zeros(1,Lfft);H_lpf(Lfft/2-BW:Lfft/2+BW-1)=1; %ideal LPF
S1_recv=SQH1.*H_lpf; % ideal filtering
s_recv1=real(ifft(fftshift(S1_recv))); % reconstructed f-domain
s_recv1=s_recv1(1:Lsig); % reconstructed t-domain
S2_recv=SQH2.*H_lpf; % ideal filtering
s_recv2=real(ifft(fftshift(S2_recv))); % reconstructed f-domain
s_recv2=s_recv2(1:Lsig); % reconstructed t-domain
% Plot the filtered signals against the original signal
figure(2);
subplot(211); sfig3=plot(t,xsig,'b-',t,s_recv1,'b-.');
legend('original','recovered');
set(sfig3,'Linewidth',2);
title('Signal {\it g} ({\it t}) and filtered 2-level PCM signal');
xlabel('time (sec.)');
subplot(212); sfig4=plot(t,xsig,'b-',t,s_recv2,'b-.');
legend('original','recovered');
set(sfig4,'Linewidth',2);
title('Signal {\it g} ({\it t}) and filtered 32-level PCM signal');
xlabel('time (sec.)');

--------------------------------

Result:

Part B:

The maximum frequency componant in the signal is 8*pi so in order to recover this signal lpf cutoff is set at 30Hz

if it is small we will lost the signal and canno recover it. if it is too big then image freq will be there in the output.

==============================

Part C

------------------------------------------------------------------

% (ExPCM.m)
% Example of sampling, quantization, and zero-order hold
clear all; close all; clc;
td=0.002; %original sampling rate 500 Hz
t=0:td:1.; % time interval of 1 second
xsig=cos(2*pi*t)+cos(2*pi*t); % 1Hz+3Hz sinusoids
Lsig=length(xsig);
Lfft=2^ceil(log2(Lsig)+1);
Xsig=fftshift(fft(xsig,Lfft));
Fmax=1/(2*td);
Faxis=linspace(-Fmax,Fmax,Lfft);
ts=0.02; % new sampling rate = 50 Hz
Nfact=ts/td;
% send the signal through a 16-level uniform quantizer
[s_out,sq_out,sqh_out1,Delta,SQNR]=sampandquant(xsig,2,td,ts);
% obtained the PCM signal which is
% - sampled, quantized, and zero-order hold signal sqh_out
% plot the orignal signal and the PCM signal in time domain
figure(1);
subplot(211);sfig1=plot(t,xsig,'k',t,sqh_out1(1:Lsig),'b');
set(sfig1,'Linewidth',2);
title('Signal {\it g}({\it t}) and its 2 level PCM signal');
xlabel('time (sec.)');
% send the signal throuhg a 4-level uniform quantizer
[s_out,sq_out,sqh_out2,Delta,SQNR]=sampandquant(xsig,32,td,ts);
% obtained the PCM signal which is
% - sampled, quantized, and zero-order hold signal sqh_out
% plot the orignal signal and the PCM signal in time domain
subplot(212);sfig2=plot(t,xsig,'k',t,sqh_out2(1:Lsig),'b');
set(sfig2,'Linewidth',2);
title('Signal {\it g}({\it t}) and its 32 level PCM signal');
xlabel('time (sec.)');

Lfft=2^ceil(log2(Lsig)+1);
Fmax=1/(2*td);
Faxis=linspace(-Fmax,Fmax,Lfft);
SQH1=fftshift(fft(sqh_out1,Lfft));
SQH2=fftshift(fft(sqh_out2,Lfft));
% Now use LPF to filter the two PCM signals
BW=10; %Bandwidth is no larger than 10Hz
H_lpf=zeros(1,Lfft);H_lpf(Lfft/2-BW:Lfft/2+BW-1)=1; %ideal LPF
S1_recv=SQH1.*H_lpf; % ideal filtering
s_recv1=real(ifft(fftshift(S1_recv))); % reconstructed f-domain
s_recv1=s_recv1(1:Lsig); % reconstructed t-domain
S2_recv=SQH2.*H_lpf; % ideal filtering
s_recv2=real(ifft(fftshift(S2_recv))); % reconstructed f-domain
s_recv2=s_recv2(1:Lsig); % reconstructed t-domain
% Plot the filtered signals against the original signal
figure(2);
subplot(211); sfig3=plot(t,xsig,'b-',t,s_recv1,'b-.');
legend('original','recovered');
set(sfig3,'Linewidth',2);
title('Signal {\it g} ({\it t}) and filtered 2-level PCM signal');
xlabel('time (sec.)');
subplot(212); sfig4=plot(t,xsig,'b-',t,s_recv2,'b-.');
legend('original','recovered');
set(sfig4,'Linewidth',2);
title('Signal {\it g} ({\it t}) and filtered 32-level PCM signal');
xlabel('time (sec.)');

--------------------------------------------------

result

--------------------------------

Part D;

The maximum freq content in the signal will be 4*pi so we will select lpf freq as 15Hz


Related Solutions

show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio...
show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds), takes Fourier transform of the signal (probably FFT).
Write a .m function file on MATLAB that reads the parameters stored in the file missile...
Write a .m function file on MATLAB that reads the parameters stored in the file missile data.txt into MATLAB. The function should have the following declaration: function [X0, Y0, Z0, m0, mf, Thmag0, theta, phi, Tburn] = read input( input filename, M id) where input filename is a string variable denoting the name of the file to be read and M_id is an integer which denotes the missile ID. The outputs are the initial position (X0, Y0, Z0), initial and...
Write a Matlab script-file probl1.m to execute the requested commands (as much as possible) in the...
Write a Matlab script-file probl1.m to execute the requested commands (as much as possible) in the exercises below. Increase N a number of times according to N = 4, 8, 16, 32, 64, 128, . . . (1) Determine for each N the (exact) error. (2) Determine for N ≥ 16 also the convergence ratio q(h/2). This script should be based on a function-file trap.m (trapezoidal integration) as follows: function [totarea] = trap(N) format long; a = 0; b =...
BY Using MATLAB software: Exercise 3: Calculation of the parameters of a dipole. % M-File: ML0804...
BY Using MATLAB software: Exercise 3: Calculation of the parameters of a dipole. % M-File: ML0804 % % Perform numerical integration to find % beam solid angle, directivity, and the % maximum power function for a given length % dipole. % % Variables % L dipole length (in wavelengths) % bL2 phase constant * length/2 % N number of theta points % th,thr angle theta in degrees,radians % dth differential theta % num,den temporary variables % F un-normalized power function...
Open travel data file <문제> 1. Set 3 hypotheses (2 main hypotheses and one interaction hypothesis)...
Open travel data file <문제> 1. Set 3 hypotheses (2 main hypotheses and one interaction hypothesis) 2. Which variable(s) are significant? and Why? 3. Which pairs of group means of travel visit are different out of three pairs in tour frequency. Which statistic did you use? 4. Use graph in order to interpret how travel frequency affects travel attitude for different sex? sex frequency attitude 1   1   2 1   1   3 1   1   4 1   1   4 1   1   2...
Query the user for the name of a file. Open the file, read it, and count...
Query the user for the name of a file. Open the file, read it, and count and report the number of vowels found in the file. Using C++.
Fluid Mechanics Friction Problem: Write one MATLAB m-file that solves the Type I and II problems...
Fluid Mechanics Friction Problem: Write one MATLAB m-file that solves the Type I and II problems presented in class based on the file posted for the Type III problem (use Colebrook to estimate f). Type I: Solve hL for v=0.74x10-5ft^2/s, D=3 in, L=1000 ft, e=0.006 in, and Re=80000. f=0.0258 from Moody Chart. Type II: Solve Q for v=10^-6 m^2/s, D=0.2 m, L=500 m, e=0.046 mm, and hL=30m. Use “rough” Colebrook to generate an estimate for f.
1) Show that if A is an open set in R and k ∈ R \...
1) Show that if A is an open set in R and k ∈ R \ {0}, then the set kA = {ka | a ∈ A} is open.
1. Create one XML data file and one DTD file for the entire data set (using...
1. Create one XML data file and one DTD file for the entire data set (using a subset of SQL assignment – see below). [Use of ID and IDREF are not required.] 2. Write and execute XML statements for the following two queries: Q1. Find the name of an employee who lives in Lincoln and works in Omaha. Q2. Find salaries of employees who live in the same cities as the companies for which they work. [You can replace one...
Describe how to open a file in Excel? What is the difference between opening a file...
Describe how to open a file in Excel? What is the difference between opening a file and creating a new file in Excel?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT