Question

In: Electrical Engineering

Exercise 2.1: Basic digital signals (a) Write a MATLAB program to generate and display (using the...

Exercise 2.1: Basic digital signals (a) Write a MATLAB program to generate and display (using the stem function) the signals defined in Table 1. The MATLAB code of the first signal (dirac) is given in the report template as an example. (b) Write a MATLAB function [x, t] = sin_NU(f0, fs, T) to generate a sine signal. The output parameters x and t are the signal and time vectors, respectively. The input parameters are f0 (signal frequency in Hz), fs (sampling frequency in Hz), T (signal duration in sec.). (c) Test your sin_NU function with the input parameter values .... and display the result using the plot function. List of basic digital signals to generate: - Dirac (Unit Response) - Unit step (Heaviside step) - Sign - Rectangle - Sine - Sine cardinal Exercise 2.2: Audio aliasing To illustrate the aliasing phenomenon, let’s perform two simple experiments allowing us to “hear” it. Using the sin_NU function of Exercise 1: (a) Generate two 1 kHz sine signals (2 seconds duration), first signal at 20 kHz sample frequency and second signal at 1.5 kHz sample frequency; (b) On the same graph, use the plot function to display the two signals versus t in the range 0 < t < 5 msec.; (c) Listen to the two signals one after another using the function soundsc(x, fs); and (d) Give your interpretation of this listening. Exercise 2.3: Quantization Quantization is done by replacing each value of an analog signal x(t) by the value of the nearest quantization level. To exemplify this operation, let’s simulate an unipolar ADC (Analog to Digital Converter) having the technical specifications: R = 10 Volts (full-scale range) and B = 3 (number of bits). (a) Write a MATLAB function y = adc_NU(x, R, B) where x and y are vectors containing the input signal and the quantized signal, respectively; (b) Test your function with an input ramp signal ranging from -5 to 15 Volts (1 volt per step); and (c) On the same graph, use the plot and stem functions to display the input signal and quantized signal, respectively.

Solutions

Expert Solution

Hello,
       Please find the answers (till exercise 2.2) attached below. If the answer has helped you please give a double thumbs up rating. Thank you and have a nice day!

For part a) please provide the table1

b)

The function definition is:

function [x, t] = sin_NU(f0, fs, T);

t = 0:1/fs:T;
x = sin(2*pi*f0*t);

end


c) Test the above with this code:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% function testing

f0 = 5; fs = 100; T = 2;
[x, t] = sin_NU(f0, fs, T);
plot(t,x);
grid;
xlabel('Time (s)');
title('SIne wave with f = 5Hz')

You will get the following output:

ex1a) and b) Please run the following program:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% audio aliasing

f0 = 1000; fs1 = 20000;fs2 = 1500; T = 2;           % signal parameters
[x1, t1] = sin_NU(f0, fs1, T);                       % x1 is sampled at 20K
[x2, t2] = sin_NU(f0, fs2, T);                       % x2 is sampled at 1.5K
[x11, t3] = sin_NU(f0, fs1, 5e-3);                       % signals for plotting
[x21, t4] = sin_NU(f0, fs2, 5e-3);                    
subplot(2,1,1)
plot(t3,x11);
grid;
xlabel('Time (s)');
title('SIne waves with f = 1000Hz and fs1 = 20K, fs2 = 1.5K');
subplot(2,1,2)
plot(t4,x21);
grid;
xlabel('Time (s)');

**** End of Code ****

Output:

c) For listening to the sounds run the following code after running the code in part a) above:

soundsc(x1, fs1)
pause(3);
soundsc(x2, fs2)

d) You will notice a shriller sound in the first case. This is because since the sound has not been sampled properly in the second case, it will lose information related to its contents and appear to be of a smaller frequency.


Related Solutions

Using If-Else conditional statement write a Visual Basic Program to display: (i) “STOP” if the user...
Using If-Else conditional statement write a Visual Basic Program to display: (i) “STOP” if the user enters “R” (ii) “CAUTION” if the user enters “Y” (iii) “GO” if the user enters “G” (iv) “Invalid” if the user enters any other character
By using MATLAB software: Exercise 2: Generate radiation pattern for a dipole as its length varies....
By using MATLAB software: Exercise 2: Generate radiation pattern for a dipole as its length varies. % M-File: ML0803 % % Dipole antenna movie shows radiation % pattern as dipole length grows from 0.1 % lambda to 2.1 lambda. % % Variables % L dipole length (in wavelengths) % bL2 phase constant * length/2 % N number of theta points % th,thr angle theta in degrees,radians % num,den temporary variables % F un-normalized power function clc %clears the command window...
Write a verilog code for digital clock and display it’s seven segment using fpga?
Write a verilog code for digital clock and display it’s seven segment using fpga?
Using c++, write a program that will display your name as a void function then will...
Using c++, write a program that will display your name as a void function then will perform the following by user-defined functions: a. to compute for the sum of two numbers (n1, n2) using function.
Part 2: MATLAB Exercise 1 (50 pts) Write a program that tells the user if a...
Part 2: MATLAB Exercise 1 (50 pts) Write a program that tells the user if a city of their choice is in a tropical, temperate, or polar region. Use the cities.txt file provided in the Files section of this class. Your program should read the data in that file, find the city given by the user, and return a text message with the information. If the city is not found, your program should write a message accordingly. To decide which...
(Using Matlab) and "while" function 1.   Write a program that prompts the User for if they...
(Using Matlab) and "while" function 1.   Write a program that prompts the User for if they would like to enter a real number. If yes, prompt the User for the real number. Continue to do this until the User enters “no” to the first question. After the User enters “no”, display the average of all the numbers entered. (Using Matlab) and "while" function 2.   Write a program that prompts the User for if they would like to enter a real...
Using Matlab, write code to generate Three signal components We will use a sum of sinusoids,...
Using Matlab, write code to generate Three signal components We will use a sum of sinusoids, all of which are sampled at 10 kHz. Signal 1 should contain a sum of sinusoids with frequencies at 25Hz, 40Hz and 75Hz. Signal 2 should contain a sum of sinusoids with frequencies at 600Hz, 730Hz, and 800Hz. Signal 3 should contain a sum of sinusoids with frequencies at 3500Hz, 4000Hz, and 4200Hz. Choose a variety of amplitudes and phase shifts for the sinusoids....
Using python Write a program that displays all of states in the U.S. and display each...
Using python Write a program that displays all of states in the U.S. and display each state that begins with the letter A.
Write a program to display privilege list of the roles and role list for privileges using...
Write a program to display privilege list of the roles and role list for privileges using many to many concept. Problem Specification: 1. Prefill the data for roles and privileges. 2. Create a menu 1. Assign privilege 2. Cancel privilege 3. Search privilege by role 4. Search role by privilege. 3. Assign privilege -- To assign specific privilege for role. 4. Cancel Privilege -- To cancel specific privilege for role. 5. Search privilege by role -- To display all the...
1- Write a program that will display the following series of integers using iterative statement of...
1- Write a program that will display the following series of integers using iterative statement of your choice, and terminate the iteration once it is larger than 200. 1, 3, 7, 13, 21, 31, 43, … use only C++!!
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT