Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views5 pages

Mathlab Program On Sinusoidal Wave

Math lab program on sinusoidal wave

Uploaded by

elvis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

Mathlab Program On Sinusoidal Wave

Math lab program on sinusoidal wave

Uploaded by

elvis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 5
NAME: MBEBIE ELVIS CHIEMELIE DEPARTMENT: MECHATRONICS ENGINEERING REG, NO: 20151012336T COURSE CODE: MCE 503 ASSIGNMENT DATE: NOVEMBER, 2021 QUESTION 1 Given a sinusoidal waveform of 100 Hz, x(t) = 4.5sin(2m + 100t) sample it at 8,000 samples per second and 1. Write a MATLAB program to quantize x(t) using a 6-bit bipolar quantizer to obtain the quantized signal x,, assuming that the signal range is from -6 to § volts; 2. Plot the original signal and quantized signal; 3. Calculate the SNR due to quantization using the MATLAB program. fs = 8000; % Sampling rate T = 1/Fs5 % Sampling interval t = 0:7:0.025 % Duration of @.02 second sig = 4.5*sin(2*pi*100*t); % Generate sinusoids bits = 6; Ig = length(sig); % Length of signal vector sig for x = 1:lg [index(x) pq] biquant(bits, -5,5, sig(x)); % Output quantized index end for x = a:1g asig(x) = bigtdec(bits, -5,5, Index(x))3 % Recover the quantized value end solution (2) - THE ORIGINAL hold on; grid on; stairs(t, qsig); plot(t, sig); xlabel('Time (sec.)')3 ylabel('Quantized x(n)')3 hold off Quantized x(n) 0 0.002 0,004 0.006 0.008 0.01 0012 0014 0016 0018 0.02 Time (sec.) solution (3) - SNR - SIGNAL TO NOISE RATIO gerr = qsig - sigs disp(‘Signal to noise ratio due to quantization noise’) Signal to noise ratio due to quantization noise snr(sig,qsig) ans = -0.0163 cle; clear; clear values; clear all; QUESTION 2 Given a signal waveform, x(t) = 3.25sin(2m + 50t) +1. 2s5c0s(2 + 100¢ -t) sample it at 8,000 samples per second and 1. write a MATLAB program to quantize x6tb using a 6-bit bipolar quantizer to obtain the quantized signal xq, assuming that the signal range is from -5 to 5 volts; 2. Plot the original signal and quantized signal; 3. Calculate the SNR due to quantization using the MATLAB program solution (1 fs = 8000; % Sampling rate T = 1/fs3 % Sampling interval t = 0:7:0.025 % Duration of @.02 second sig = 3.25%sin(2*pitso*t) + 1.25*cos(2*pittoo*t+pi/4) ; % Generate sinusoids bits = 6; Ig = length(sig)s % Length of signal vector sig for x = 1:1 [Index(x) pq] = biquant(bits, -5,5, sig(x)); % Output quantized index end for x = a:1g asig(x) ~ bigtdec(bits, -5,5, Index(x))3 % Recover the quantized value end solution (2) - THE ORIGINAL SIGNAL AND THE QUANTIZED SIGNAL plot(t, sig); grid on; hold on; stairs(t, qsig); xlabel('Time (sec.)')3 ylabel('Quantized x(n)'); hold off; 4 Quantized x(n) 2 0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0016 0018 0.02 Time (sec.) solution (3) - SNR - SIGNAL TO NOISE RATIO gerr = qsig - sigs disp('Signal to noise ratio due to quantization noise’) Signal to noise ratio due to quantization noise snr(sig,qsig) ans = 0.0288 cle; clear; clear values; clear all; FUNCTIONS USED function [ I, pq]= biquant (NoBits, Xmin, Xmax, value) function pq % biquant(NoBits, Xmin, Xmax, value) This routine is created for simulation of the uniform quantizer. % % % % NoBits: number of bits used in quantization % Xmax: overload value % Xmin: minimum value % value: input to be quantized % pq: output of quantized value % I: coded integer index L = 2°NoBits; delta = (Xmax-Xmin)/L3 I = round((value-Xmin)/delta) 5 if (I == L) Teta; end ift

You might also like