In-Person Exams

Midterms: 2/24, 3/24, 4/28
Final: 5/8

.

Matlab Scripts

• Finding quantizing step size of digital signal: quantsteps.m
• Find SNR of digital signal: snr.m
• Find SNR of mu-law digital signal: nonlinear.m (comments in script not correct at the moment.)
• Discrete Fourier Transform: dft.m
• Taking the FFT, and calculating the frequencies it uses: fft_demo1.m
• Comparing the FFT output to DFT (Houston; we have a problem): fft_demo2.m
• Fixing the FFT/DFT mismatch problem by using zero padding: fft_demo3.m
• An easier way to do zero padding in matlab: fft_demo4.m
• A selection of weighting windows: fft_demo5.m
• The Kaiser family of weighting windows: fft_demo6.m
• Two sine waves, about the same frequency, about the same amplitude: fft_demo7.m
• Two sine waves, about the same frequency, very different amplitudes: fft_demo8.m
• Two sine waves, very different frequencies, very different amplitudes: fft_demo9.m
• Spectrum constant from DC to 100 Hz: fft_demo10.m
• Spectrum constant from 400 Hz to 600 Hz Hz: fft_demo11.m
• Spectrum Kaiser Windows (and DC signal): fft_demo12.m
• Spectrum of white noise: fft_demo13.m
• Spectrum of lots of white noise: fft_demo14.m
• Periodogram: fft_periodogramkk.m
• Designing an FIR filter using IFFT: firfilter1.m
• Using circular shifts of IFFT output to get you choices on filter impulse responses: firfilter2.m
• Analyzing an ARMA IIR filter. Frequency response via Z transform, impulse response, frequency response via fft of the impulse response, pole/zero plots: FilterAnalysis.m
• Chirp signals: ChripExample.m
• Pole Zero Analysis of analog filters. Define pole/zero locations in s-plane in script, then it will plot pole/zero plot and frequency response: polezeroanalysis2.m
• Pole Zero Analysis of discrete time filters. Define pole/zero locations in z-plane in script, then it will plot pole/zero plot and frequency response: polezeroanalysis3.m
• Interactive pole zero analysis of discrete time filters polezeroanalysis4.zip To run, do the following:
• Download the .zip file shown above. Uncompress it, and store the three .m files you find in the same directory.
• Execute the polezeroanalysis4.m file you should see from the previous step.
• It will put two figures on the screen, on top of each other. Separate them on the screen, so you can see them both.
• Click on the header bar at the top of the pole/zero plot figure (the one with the circle drawn in it).
• Move your mouse around the pole/zero figure. You should see an "x" following your mouse. This is a pole. You should also see the frequency response update, as you move the pole around.
• Right-click on your mouse. That will fix the pole at it's current location, and give you a second pole to move around. Continued right clicks will give you yet more poles.
• Left-click your mouse, and you should see the "x" on your cursor change to a "o". You are now dragging a zero around the pole/zero plot. A left click will drop a zero at that location, and give you a new one.
• Continued right-clicks will toggle back-and-forth between poles and zeros.
• It helps if you move the mouse slowly, as on my PC Matlab can't keep up with quick movements.
• Notch filter program #2. Implement a moving average (MA) notch filter that has two zeros, and no poles (actually a second order pole at z=0). The program reads in an audio signal, adds a big sine wave to it, and then removes the sine wave with the MA notch filter. There is a transient at the start that goofs up things just a little bit, but is easy to fix. The sine wave gets removed, but there is noticeable distortion to the signal. notch2.m
• Notch filter program #3. An ARMA notch filter. The poles are moved away from the origin, and placed near the zeros. This narrows the notch the in the frequency domain, hence reducing the distortion on the signal. But it does give me a longer transient, which is getting to be a problem notch3.m
• Notch filter program #4. A very narrow notch filter. The steep change in the frequency domain corresponds to a long impulse response - and a long transient. In digital filters, that can be the limiting factor in the design. We may not be willing to tolerate the very long transients we get with these nearly ideal filters. notch4.m
• Notch filter program #5. A reversed-time ARMA notch filter. By filtering the signal in reverse-time, we can put the transient at the end of the signal, rather than the beginning. notch5.m
• Notch filter program #6. By combining the forward-time and reverse-time notch filters, we can essentially eliminate the transient. The result is not perfectly distortion-free, but it is reasonably good in my opinion. We can remove a sine wave that is 70 dB more powerful than the voice signal, with what appears to be minimal distortion of the original audio signal to a casual listener. notch6.m. All the notch filter programs assumed you knew the frequency of the tone you want to remove to start with. There are something called adaptive filters that can figure out the frequency of the tone, and then remove it - all without human intervention. We cover those filters in the graduate level DSP course.

Open Source Matlab Equivalent

This class will use Matlab. It is accessable on many university computers, including those in the ECE building. You may also wish to consider purchasing a copy of Matlab to use on your personal computer. The Matlab and Simulink Student Suite, available for about \$100, will run all the scripts used in this class.

If you prefer free and open-source software, there are packages that have the goal of being compatible with Matlab. One of these is the GNU Octave package. It runs on Windows, iOS and Linux machines, and is reasonably easy to install. The user interface is not as polished as Matlab's, and it does not have some of the more advanced features like Simulink. However, Octave should easily run all of the scripts needed for this class.

Here are some installation directions for GNU Octave:

1. Go to the web page https://www.gnu.org/software/octave/. Click on the blue "Download" button. Click on the gray tab that corresponds to the operating system you are using. I'm running it on a laptop running Windows 10, so I clicked the gray "Windows" tab. Select the best version. I went to the "Windows-64 (recommended)" list and downloaded "octave-6.1.0-w64-installer.exe (~ 300 MB)"
2. After the installer.exe file was downloaded, I ran it in the same way as any other Windows 10 program, and eventually got an icon on my desktop for Octave. Double-clicking on that started Octave.
3. For some of the scripts in this class, you will need the Octave control and signal packages. These are not part of the standard Octave install, but are freely available. If you want to see the list of all packages, go to the sourceforge web site https://octave.sourceforge.io/packages.php. You don't have to look at the sourceforge web site, as it is possible to download, install, and load the packages from the Octave command window, as described below.
4. Start Octave, and go to the Command Window. You should see a >> prompt.
5. Download and install the control package. You can do this from the Command Window. At the >> prompt enter

>> pkg install -forge control

6. Wait while Octave goes out to the internet, downloads the file, and installs it. This took several minutes on my laptop at home, but I have a slow internet connection, and firewall and virus detection software that looks over everything I download. In the Octave Command Window I saw two identical warning messages about LFLAGS. Eventually the Command Window gave me a message that started "For information about changes ..." and I got the >> prompt again.

> pkg install -forge signal

This went faster for me, and generated no warnings.
8. Even though both packages are now "installed", you can't use them until they are "loaded". There are two ways to load them. In the Command Window, you can enter the following two commands:

While that's pretty easy, you will have to remember to do it each time you start Octave. I found it easier to put the commands in Octave's configuration file, which is executed every time Octave is started. To do this, in the Octave Command Window enter

> edit '~/.octaverc'

Notice that the command has two single quotes, a tilde, and a period that all must be entered exactly as typed. If Octave tells you the file does not exist, and asks you if you want to create it, pick YES. Enter the following two lines in that file