User Tools

Site Tools


ecen_380_assignments

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ecen_380_assignments [2015/11/19 19:24]
petersen
ecen_380_assignments [2016/05/16 10:02] (current)
a_west [Chapter 1: LTI Systems]
Line 1: Line 1:
-===== ECEn 380 MATLAB Assignments =====+====== ECEn 380 MATLAB Assignments =====
 + 
 +Welcome to the 380 section for the ECEn MATLAB wiki. For a brief refresher on MATLAB, [[ matlab_guide | look here.]] 
 + 
 +The syntax for the problem numbers is such: 
 +<​code>​ 
 +[Language][Class].[Book authors][Chapter].[Section].[Problem] 
 +</​code>​ 
 + 
 +Thus for help on problem "​MT380.UY6.8.1",​ for example, you can refer to section 6-8 in the textbook (page 279).
  
 <ifauth, @admin> <ifauth, @admin>
Line 6: Line 15:
  
 ^ Chapter ^  Assignments ​                                            ​^ ​ Course Topic                   ^ MATLAB Topic                                                                                                                                                                  ^          ^ Chapter ^  Assignments ​                                            ​^ ​ Course Topic                   ^ MATLAB Topic                                                                                                                                                                  ^         
-| Ch 1    | [[ecen_380_assignments#​MT380.UY1 ​MT380.UY1 ​]]           ​| ​Signals ​                                                                                                                                                                                                      ​+| Ch 1    | [[ecen_380_assignments#​Chapter 1: Signals ​Signals ​]]           ||| 
-| :::     | [[ecen_380_assignments#​MT380.UY1.2.1 ​| MT380.UY1.2.1 ]]   | Signal Transformations ​         | [[matlab_guide#​Array Operations| Array Operations]],​[[matlab_guide#​Graph Function| plot]] ,​[[matlab_guide#​Annotation| Graph Annotation]] ,​[[matlab_guide#​Figures| Figures]] ​  |  +| :::     | [[ecen_380_assignments#​Signal Transformations ​| MT380.UY1.2.1 ]]   | Signal Transformations ​         | [[matlab_guide#​Array Operations| Array Operations]],​[[matlab_guide#​Graph Function| plot]] ,​[[matlab_guide#​Annotation| Graph Annotation]] ,​[[matlab_guide#​Figures| Figures]] ​  |  
-| :::     | [[ecen_380_assignments#​MT380.UY1.5.1 ​| MT380.UY1.5.1 ]]   | Signal Power and Energy ​        ​| ​                                                                                                                                                               sum (used to evaluate numerical integrals) ​          | +| :::     | [[ecen_380_assignments#​Signal Power and Energy ​| MT380.UY1.5.1 ]]   | Signal Power and Energy ​        ​| ​                                                                                                                                                               sum (used to evaluate numerical integrals) ​          | 
-| Ch 2    | [[ecen_380_assignments#​MT380.UY2 ​MT380.UY2 ​]]           ​| ​LTI Systems ​                                                                                                                                                                                                  ​|+| Ch 2    | [[ecen_380_assignments#​Chapter 2: LTI Systems ​Linear Time-Invariant (LTI) Systems ​]]           |||
 | :::     | [[ecen_380_assignments#​MT380.UY2.3.0 | MT380.UY2.3.0 ]]   | Convolution ​ Aid                |                                                                                                                                                                               ​| ​ | :::     | [[ecen_380_assignments#​MT380.UY2.3.0 | MT380.UY2.3.0 ]]   | Convolution ​ Aid                |                                                                                                                                                                               ​| ​
 | :::     | [[ecen_380_assignments#​MT380.UY2.3.1 | MT380.UY2.3.1 ]]   | Convolution with function files |  [[matlab_guide#​Function Files| Function Files]], [[matlab_guide#​For-loop| For-loop]] ​                                                                                        ​| ​ | :::     | [[ecen_380_assignments#​MT380.UY2.3.1 | MT380.UY2.3.1 ]]   | Convolution with function files |  [[matlab_guide#​Function Files| Function Files]], [[matlab_guide#​For-loop| For-loop]] ​                                                                                        ​| ​
Line 16: Line 25:
 | :::     | [[ecen_380_assignments#​MT380.UY2.8.1 | MT380.UY2.8.1 ]]   | Imp.Resp. of 2nd Ord LCCDEs ​    ​| ​   [[matlab_guide#​Roots| Roots]] ​                                                                                                                                             |  | :::     | [[ecen_380_assignments#​MT380.UY2.8.1 | MT380.UY2.8.1 ]]   | Imp.Resp. of 2nd Ord LCCDEs ​    ​| ​   [[matlab_guide#​Roots| Roots]] ​                                                                                                                                             | 
 | :::     | [[ecen_380_assignments#​MT380.UY2.9.1 | MT380.UY2.9.1 ]]   | Car Suspension ​                 |    Review ​            ​ | | :::     | [[ecen_380_assignments#​MT380.UY2.9.1 | MT380.UY2.9.1 ]]   | Car Suspension ​                 |    Review ​            ​ |
-| Ch 3    | [[ecen_380_assignments#​MT380.UY3 ​MT380.UY3 ​]]           ​| ​Laplace Transform ​                                                                                                                                                                                            ​|+| Ch 3    | [[ecen_380_assignments#​Chapter 3: Laplace Transform ​Laplace Transform ​]]           |||
 | :::     | [[ecen_380_assignments#​MT380.UY3.2.1 ​ | MT380.UY3.2.1 ]]  | Poles and Zeros                 ​| ​   [[matlab_guide#​Mesh| Mesh]] ​                                    ​  ​   | | :::     | [[ecen_380_assignments#​MT380.UY3.2.1 ​ | MT380.UY3.2.1 ]]  | Poles and Zeros                 ​| ​   [[matlab_guide#​Mesh| Mesh]] ​                                    ​  ​   |
-| Ch 4    | [[ecen_380_assignments#​MT380.UY4 ​MT380.UY4 ​]]           ​| ​App. of the L-Transform ​                                                                                                                                                                                      ​|+| Ch 4    | [[ecen_380_assignments#​Chapter 4: Applications of the Laplace Transform ​Applications of the Laplace Transform ​]]           |||
 | :::     | [[ecen_380_assignments#​MT380.UY4.5.1 ​ | MT380.UY4.5.1 ]]  | Op-Amp Circuits ​                ​| ​  ​Review ​                                                                                                                                                                     | | :::     | [[ecen_380_assignments#​MT380.UY4.5.1 ​ | MT380.UY4.5.1 ]]  | Op-Amp Circuits ​                ​| ​  ​Review ​                                                                                                                                                                     |
-| Ch 5    | [[ecen_380_assignments#​MT380.UY5 ​MT380.UY5 ​]]           ​| ​Fourier Analysis Techniques ​                                                                                                                                                                                  ​|+| Ch 5    | [[ecen_380_assignments#​Chapter 5: Fourier Analysis Techniques ​Fourier Analysis Techniques ​]]           |||
 | :::     | [[ecen_380_assignments#​MT380.UY5.4.1 | MT380.UY5.4.1 ]]   | Fourier Series Coefficients ​    ​| ​  ​[[matlab_guide#​For-loop| For-loop]] ​                                                                                                                                        | | :::     | [[ecen_380_assignments#​MT380.UY5.4.1 | MT380.UY5.4.1 ]]   | Fourier Series Coefficients ​    ​| ​  ​[[matlab_guide#​For-loop| For-loop]] ​                                                                                                                                        |
 | :::     | [[ecen_380_assignments#​MT380.UY5.12.1 | MT380.UY5.12.1 ]] | Circuit Analysis with Fourier ​  ​| ​  ​Review ​                                                                                                                                                                     | | :::     | [[ecen_380_assignments#​MT380.UY5.12.1 | MT380.UY5.12.1 ]] | Circuit Analysis with Fourier ​  ​| ​  ​Review ​                                                                                                                                                                     |
-| Ch 6    | [[ecen_380_assignments#​MT380.UY6 ​MT380.UY6 ​]]           ​| ​Apps of the Fourier Trans. ​     ​                                                                                                                                                                              ​|+| Ch 6    | [[ecen_380_assignments#​Chapter 6: Applications of the Fourier Transform ​Applications of the Fourier Transform ​]]           |||
 | :::     | [[ecen_380_assignments#​MT380.UY6.8.1 | MT380.UY6.8.1 ]]   | Butterworth Filters ​            ​| ​ Review ​                                                                                                                                                                      | | :::     | [[ecen_380_assignments#​MT380.UY6.8.1 | MT380.UY6.8.1 ]]   | Butterworth Filters ​            ​| ​ Review ​                                                                                                                                                                      |
 |    :::  | [[ecen_380_assignments#​MT380.UY6.12.1 | MT380.UY6.12.1 ]] | Sampling Theorem ​               |  [[matlab_guide#​fopen| fopen]],​[[matlab_guide#​fscanf| fscanf]],​[[matlab_guide#​fclose| fclose]], [[matlab_guide#​interp| Interpolate]],​[[matlab_guide#​sound| sound]] ​           | |    :::  | [[ecen_380_assignments#​MT380.UY6.12.1 | MT380.UY6.12.1 ]] | Sampling Theorem ​               |  [[matlab_guide#​fopen| fopen]],​[[matlab_guide#​fscanf| fscanf]],​[[matlab_guide#​fclose| fclose]], [[matlab_guide#​interp| Interpolate]],​[[matlab_guide#​sound| sound]] ​           |
-| Ch 7    | [[ecen_380_assignments#​MT380.UY7 | MT380.UY7 ]]           | Discrete-Time Signals and Syst  ​                                                                                                                                                                              ​|+| Ch 7    | [[ecen_380_assignments#​Chapter 7: Discrete-Time Signals and Systems ​| Discrete-Time Signals and Systems ]]           |||
 | :::     | [[ecen_380_assignments#​MT380.UY7.2.1 | MT380.UY7.2.1 ]]   | D-Time Signal Functions ​        ​| ​  ​rat ​                                                                                                                                                                        | | :::     | [[ecen_380_assignments#​MT380.UY7.2.1 | MT380.UY7.2.1 ]]   | D-Time Signal Functions ​        ​| ​  ​rat ​                                                                                                                                                                        |
 | :::     | [[ecen_380_assignments#​MT380.UY7.13.1 | MT380.UY7.13.1 ]] | D-Time Fourier Series ​          ​| ​ Review ​                                                                                                                                                                      | | :::     | [[ecen_380_assignments#​MT380.UY7.13.1 | MT380.UY7.13.1 ]] | D-Time Fourier Series ​          ​| ​ Review ​                                                                                                                                                                      |
-Fun APP | [[ecen_380_assignments#​Music Harmonics | Music Harmonics ]] | FFT,Fourier Series Coeff        | FFT Plot+:::     | [[ecen_380_assignments#​MT380.UY7.15.1 | MT380.UY7.15.1 ]] | Discrete Fourier Transform ​     |  Review ​                                                                                                                                                                            ​| ​                 
 +| Extras  ​| [[ecen_380_assignments#​Music Harmonics | Music Harmonics ]] | FFT,Fourier Series Coeff        | FFT Plot
  
  
 +====== Chapter 1: Signals ======
  
- +===== Signal ​Transformations ​=====
-===== Signal ​Transformation ​=====+
  
 ==== MT380.UY1.2.1 ====  ==== MT380.UY1.2.1 ==== 
  
-== Discription ​==+== Description ​==
  
-<​file>​+<​file ​| MT380.UY1.2.1.txt ​>
  ​Signal Transformations  ​Signal Transformations
  
Line 185: Line 195:
 </​ifauth>​ </​ifauth>​
  
 +====== Chapter 2: LTI Systems ======
  
 ===== Convolution Aid ===== ===== Convolution Aid =====
Line 701: Line 712:
  
 </​ifauth>​ </​ifauth>​
 +
 +====== Chapter 3: Laplace Transform ======
  
 ===== Laplace Transform Aid ===== ===== Laplace Transform Aid =====
Line 799: Line 812:
  
 </​ifauth>​ </​ifauth>​
 +
 +====== Chapter 4: Applications of the Laplace Transform ======
  
 ===== Op-Amp Circuits ===== ===== Op-Amp Circuits =====
Line 842: Line 857:
  
 </​ifauth>​ </​ifauth>​
 +
 +====== Chapter 5: Fourier Analysis Techniques ======
  
 ===== Fourier Series Coefficients ===== ===== Fourier Series Coefficients =====
Line 1048: Line 1065:
 </​ifauth>​ </​ifauth>​
  
 +====== Chapter 6: Applications of the Fourier Transform ======
  
 ===== Butterworth Filters ===== ===== Butterworth Filters =====
Line 1438: Line 1456:
 {{:​380matlab:​solutions:​ch6:​pianos8ff.wav|}} {{:​380matlab:​solutions:​ch6:​pianos8ff.wav|}}
  
 +
 +====== Chapter 7: Discrete-Time Signals and Systems ======
  
 ===== D-Time Signal Functions ===== ===== D-Time Signal Functions =====
Line 1534: Line 1554:
 </​ifauth>​ </​ifauth>​
  
 +===== Discrete Fourier Transform =====
 +==== MT380.UY7.15.1 ====
 +
 +<​file>​
 + MT380 UY7 15 1 Discrete Fourier Transform
 +
 +Objective: The objective of the assignment is to create a function that
 +           can implement the Discrete Fourier Transform and plot it.  We
 +           have provided all of the code except for the actual
 +           ​implementation of the DFT, but please go through the code
 +           ​carefully and try to understand it.
 +
 + ​Commands:​ Review
 + ​Exercise:​ You are given a file that represents a non-periodic signal. In
 +           this exercise you will (1) window the signal, (2) apply the DFT 
 +           to the windowed signal, (3) and then plot the signals.
 +
 +           a) Begin by importing the signal file (file located below), ​
 +              and storing its contents to a
 +              variable. This variable will hold the data points of the
 +              non-periodic signal. ​
 +                 % this command will open the file. You will need to replace
 +                 % filename with the name of the file.
 +                ​
 +                 ​fileID = fopen('​filename.txt'​);​
 + 
 +                 % the variable signal will contain the data points that represents the
 +                 % signal. ​
 +                 % the variable num_of_samples contains the number of data points in the
 +                 % file.
 +                 ​[original_signal,​num_of_samples] = fscanf(fileID,'​%e'​);​
 +                 % transpose the signal
 +                 ​original_signal = original_signal';​
 + 
 +                 % Since you have what you need, you can close the file.
 +                 ​fclose(fileID);​
 +                 % Below is the sample rate at which the original signal ​
 +                 % was created, in samples/​second.
 +                   ​sample_rate = 1200;
 +
 +                 % plot the signal as a function of n(index)
 +                 ​figure(1);​
 +                 ​subplot(2,​2,​1);​
 +                 ​plot(original_signal);​
 +                 ​title('​original signal'​);​
 +
 +               ​Notice how the bulk of the information is around the center
 +               of the plot, and that there is little non-zero data at
 +               other locations. We will window the signal to isolate the
 +               bulk of the data. This limits the number of sampled values,
 +               and thus reducing the number of computations. ​
 +
 +                 %the two parameters below will index '​original signal'​ around the bulk of
 +                 %the information.
 +                 ​n_window_lower = 320;
 +                 ​n_window_upper = 2119;
 + 
 +                 % window the original signal
 +                 ​windowed_signal = original_signal(n_window_lower:​n_window_upper);​
 + 
 +               Plot the windowed_signal and notice the difference between
 +               the '​original_signal'​ and the '​windowed_signal'​.
 +
 +                 % plot the windowed_signal as a function of n
 +                 ​subplot(2,​2,​2);​
 +                 ​plot(windowed_signal);​
 +                 ​title('​windowed signal'​);​
 +
 +           b) Create a function file that will perform the DFT. A skeleton
 +              of the function file is provided below. I have created the
 +              function file to operate in two modes depending on how many
 +              parameters you pass into the function file. All you need to
 +              do is modify the code that is between the comment lines to
 +              actually implement the DFT summation equation.
 +
 +                                   ​Comment line
 +               ​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 +
 +                 ​function [Xk, f] =  myDFT(signal,​sample_rate)
 + 
 +                 % Xk is an array of the DFT complex coefficients
 +                 % f is an array of the frequencies that correspond to Xk
 +                 % signal is a variable that contains the data points of your signal
 +                 % sample_rate is the rate at which the signal was samples/​created
 + 
 +                 % This function file supports two modes. The first mode is the generic DFT,
 +                 % and is triggered when only yhe signal is passed to the function. Ex
 +                 ​% ​      ​myDFT(windowed_signal)
 + 
 +                 % If both parameters are passed, then the function file will execute the
 +                 % second mode
 +
 +                 % Ex. myDFT(windowned_signal,​ sample_rate);​
 + 
 +                 % Checks to see how many parameters were passed in. If only one parameter
 +                 % is passed in, then the original DFT is calculated.
 +                 ​if(nargin < 2)
 +                     ​sample_rate = 1;
 +                 end
 + 
 +                 % The equation for the DFT is
 +                 % Xk = sum(x[n]*exp(-1j*k*omega_o*n),​ from n = 0 to n = No-1)
 + 
 + 
 +                 % No represents the number of sampled values
 +                 No = length(signal);​
 + 
 +                 % fundamental frequency ​
 +                 ​gamma_o = 2*pi/No;
 + 
 +                 % n is an array that indexes the data points
 +                 n = 1:​length(signal);​
 + 
 +                 % Xn are the DFT complex coefficients
 +                 Xk = zeros(1,​length(signal));​
 + 
 +                 % f is an array that will contain the frequencies (Hz) at which the DFT is
 +                 % applied
 +                 f = zeros(1,​length(signal));​
 + 
 +                 ​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 +                 ​% ​ Student will only modify the code in between the comment lines
 +                 ​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 +                 % iterates through the harmonics of gamma_o to find the DFT complex
 +                 % coefficients and the frequencies (Hz)
 +                 for k = 0:No-1;
 + 
 +                 ​Xk(k+1) = sum( %INSERT CODE HERE);
 +                 ​f(k+1) = k*gamma_o/​(2*pi)*sample_rate;​
 + 
 +                 end
 +                 ​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 +                 % Do not modify the code below
 +                 ​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 +                 % In the DFT, the values ranged from 0 to pi represent the positive
 +                 % frequencies while the values from pi to 2pi represent the negative
 +                 % frequencies Since the magnitude of the DFT is an even function we can
 +                 % get all of the necessary information from looking at the values of Xn
 +                 % that represent the frequencies from 0 to pi
 + 
 +                 ​if(nargin == 2)
 + 
 +                     Xk = 2*Xk(1:​round(length(Xk))/​2);​
 +                     ​f ​ = f(1:​round(length(f))/​2);​
 +                 end
 +
 +           c) Call the function to perform the DFT on your signal passing
 +              in only your signal to myDFT function. Call the function
 +              again, but pass in both the signal and the sample rate.
 +
 +                 % call function to perform the DFT
 +                 ​[Xn_mode1,​f_mode1] = myDFT(windowed_signal);​
 +                 ​[Xn_mode2,​f_mode2] = myDFT(windowed_signal,​sample_rate);​
 + 
 +                 % plot the DFT transform
 +                 ​subplot(2,​2,​3);​
 +                 ​plot(f_mode1,​abs(Xn_mode1));​
 +                 ​title('​DFT mode1 complex coefficients'​);​
 +                 ​xlabel('​frequency (hz)'​);​
 +                 ​ylabel('​DFT complex coefficients magnitude'​);​
 + 
 +                 ​subplot(2,​2,​4);​
 +                 ​plot(f_mode2,​abs(Xn_mode2));​
 +                 ​title('​DFT mode 2 complex coefficients'​);​
 +                 ​xlabel('​frequency (hz)'​);​
 +                 ​ylabel('​DFT complex coefficients magnitude'​);​
 +
 +           d) Question:
 +              1) Looking at the DFT mode2 plot (where you pass in the sample
 +                 rate, what frequencies are in the original signal. Hint: there are only four.
 +           ​Remember to submit your plots and code.
 +</​file>​
 +
 +== Signal File ==
 +
 +{{:​380matlab:​ch7:​mt380_uy7_15_1_s_discretefouriertransform_signal.txt|}}
 +
 +== Solution Image ==
 +
 +{{:​380matlab:​ch7:​mt380_uy7_15_1_si_discretefouriertransform_solutionimage.jpg?​400|}}
 +
 +<ifauth @admin,​@380ta>​
 +
 +== Signal Creation ==
 +
 +{{:​380matlab:​solutions:​ch7:​mt380_uy7_15_1_sc_discretefouriertransform_signalcreation.m|}}
 +
 +== Solution ==
 +
 +DFT Function File.
 +{{:​380matlab:​solutions:​ch7:​mt380_uy7_15_1_dft.m|}}
 +
 +Associated Script File
 +
 +{{:​380matlab:​solutions:​ch7:​mt380_uy7_15_1_discretefouriertransform.m|}}
 +
 +</​ifauth>​
 +
 +====== Extras ======
 ===== Music Harmonics ===== ===== Music Harmonics =====
 <​file>​ <​file>​
ecen_380_assignments.1447986258.txt.gz · Last modified: 2015/11/19 19:24 by petersen