Handout 1 - Introduction to plots in Matlab 7

Similar documents
Discrete-time equivalent systems example from matlab: the c2d command

ECE438 - Laboratory 1: Discrete and Continuous-Time Signals

Audio Processing Exercise

Lab P-6: Synthesis of Sinusoidal Signals A Music Illusion. A k cos.! k t C k / (1)

ECE438 - Laboratory 4: Sampling and Reconstruction of Continuous-Time Signals

MIE 402: WORKSHOP ON DATA ACQUISITION AND SIGNAL PROCESSING Spring 2003

4.4 The FFT and MATLAB

NENS 230 Assignment #2 Data Import, Manipulation, and Basic Plotting

Analyzing and Saving a Signal

Please feel free to download the Demo application software from analogarts.com to help you follow this seminar.

The BAT WAVE ANALYZER project

Common Spatial Patterns 3 class BCI V Copyright 2012 g.tec medical engineering GmbH

Agilent DSO5014A Oscilloscope Tutorial

Experiment 2: Sampling and Quantization

Course Web site:

ME EN 363 ELEMENTARY INSTRUMENTATION Lab: Basic Lab Instruments and Data Acquisition

Common Spatial Patterns 2 class BCI V Copyright 2012 g.tec medical engineering GmbH

1 Overview. 1.1 Digital Images GEORGIA INSTITUTE OF TECHNOLOGY. ECE 2026 Summer 2018 Lab #5: Sampling: A/D and D/A & Aliasing

1 Overview. 1.1 Digital Images GEORGIA INSTITUTE OF TECHNOLOGY. ECE 2026 Summer 2016 Lab #6: Sampling: A/D and D/A & Aliasing

Lab 1 Introduction to the Software Development Environment and Signal Sampling

UNIVERSITY OF BAHRAIN COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING

Laboratory Assignment 3. Digital Music Synthesis: Beethoven s Fifth Symphony Using MATLAB

Spectrum Analyser Basics

Design of Speech Signal Analysis and Processing System. Based on Matlab Gateway

Dektak Step by Step Instructions:

EE 350. Continuous-Time Linear Systems. Recitation 2. 1

The following exercises illustrate the execution of collaborative simulations in J-DSP. The exercises namely a

Processing data with Mestrelab Mnova

Lab experience 1: Introduction to LabView

Using Multiple DMs for Increased Spatial Frequency Response

THE BERGEN EEG-fMRI TOOLBOX. Gradient fmri Artifatcs Remover Plugin for EEGLAB 1- INTRODUCTION

Lab 5 Linear Predictive Coding

A Matlab toolbox for. Characterisation Of Recorded Underwater Sound (CHORUS) USER S GUIDE

SigPlay User s Guide

Laboratory 5: DSP - Digital Signal Processing

MATLAB Basics 6 plotting

System Requirements SA0314 Spectrum analyzer:

DSP First Lab 04: Synthesis of Sinusoidal Signals - Music Synthesis

BME 3512 Biomedical Laboratory Equipment List

OCTAVE C 3 D 3 E 3 F 3 G 3 A 3 B 3 C 4 D 4 E 4 F 4 G 4 A 4 B 4 C 5 D 5 E 5 F 5 G 5 A 5 B 5. Middle-C A-440

The Measurement Tools and What They Do

SOUND LABORATORY LING123: SOUND AND COMMUNICATION

Problem Weight Total 100

ENGIN 100: Music Signal Processing. PROJECT #1: Tone Synthesizer/Transcriber

WAVES H-EQ HYBRID EQUALIZER USER GUIDE

Figure 1: Feature Vector Sequence Generator block diagram.

TUTORIAL IGBT Loss Calculation in the Thermal Module

ECT 224: Digital Computer Fundamentals Digital Circuit Simulation & Timing Analysis

Problem Set #1 Problem Set Due: Friday, April 12

Virtual instruments and introduction to LabView

PulseCounter Neutron & Gamma Spectrometry Software Manual

PHY221 Lab 1 Discovering Motion: Introduction to Logger Pro and the Motion Detector; Motion with Constant Velocity

Agilent PN Time-Capture Capabilities of the Agilent Series Vector Signal Analyzers Product Note

User manual. English. Perception CSI Extension Harmonic Analysis Sheet. A en

GS Bloch Equations Simulator 1. GS Introduction to Medical Physics IV Exercise 1: Discrete Subjects

Quick Start manual for Nova

Analyze Frequency Response (Bode Plots) with R&S Oscilloscopes Application Note

Digital music synthesis using DSP

EASERA SysTune. Developed by. AFMG Ahnert Feistel Media Group. The creators of EASE and EASERA.

SpectraPlotterMap 12 User Guide

Introduction to S1210 EMI Pre-Compliance Test Software

Pictures To Exe Version 5.0 A USER GUIDE. By Lin Evans And Jeff Evans (Appendix F By Ray Waddington)

Rack-Mount Receiver Analyzer 101

GPA for DigitalMicrograph

USB Mini Spectrum Analyzer User s Guide TSA5G35

ECE-320 Lab 5: Modeling and Controlling a Pendulum

4. ANALOG TV SIGNALS MEASUREMENT

PS User Guide Series Seismic-Data Display

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT /12/14 BIT 10 TO 105 MSPS ADC

EE 261 The Fourier Transform and its Applications Fall 2007 Problem Set Two Due Wednesday, October 10

USER MANUAL FOR DDT 2D. Introduction. Installation. Getting Started. Danley Design Tool 2d. Welcome to the Danley Design Tool 2D program.

Topic: Instructional David G. Thomas December 23, 2015

E X P E R I M E N T 1

SEM- EDS Instruction Manual

Upgrading E-learning of basic measurement algorithms based on DSP and MATLAB Web Server. Milos Sedlacek 1, Ondrej Tomiska 2

Brain-Computer Interface (BCI)

NanoGiant Oscilloscope/Function-Generator Program. Getting Started

INDIVIDUAL INSTRUCTIONS

Electrical and Electronic Laboratory Faculty of Engineering Chulalongkorn University. Cathode-Ray Oscilloscope (CRO)

Tutorial 3 Normalize step-cycles, average waveform amplitude and the Layout program

Design of a Speaker Recognition Code using MATLAB

Manual for the sound card oscilloscope V1.41 C. Zeitnitz english translation by P. van Gemmeren, K. Grady and C. Zeitnitz

Analysis of AP/axon classes and PSP on the basis of AP amplitude

StaMPS Persistent Scatterer Practical

DSP First Lab 04: Synthesis of Sinusoidal Signals Music Synthesis. A k cos(ω k t + φ k ) (1)

Goals of tutorial. Introduce NMRbox platform

NJU26125 Application Note PEQ Adjustment Procedure Manual New Japan Radio Co., Ltd

WJ-HD616K/716K Quick Reference Guide

Automatic LP Digitalization Spring Group 6: Michael Sibley, Alexander Su, Daphne Tsatsoulis {msibley, ahs1,

Logic Analyzer Auto Run / Stop Channels / trigger / Measuring Tools Axis control panel Status Display

EE369C: Assignment 1

StaMPS Persistent Scatterer Exercise

3 CHOPS - LIP SYNCHING

BBN ANG 141 Foundations of phonology Phonetics 3: Acoustic phonetics 1

Experiment: Real Forces acting on a Falling Body

Linrad On-Screen Controls K1JT

AMIQ-K2 Program for Transferring Various-Format I/Q Data to AMIQ. Products: AMIQ, SMIQ

USER S GUIDE DSR-1 DE-ESSER. Plug-in for Mackie Digital Mixers

WAVES Cobalt Saphira. User Guide

AFM1 Imaging Operation Procedure (Tapping Mode or Contact Mode)

Transcription:

SPHSC 53 Speech Signal Processing UW Summer 6 Handout - Introduction to plots in Matlab 7 Signal analysis is an important part of signal processing. And signal analysis is not complete without signal visualization. Matlab has a large number of data visualization tools, which we will introduce and explore in this handout. Before going into the plotting functions of Matlab, it may be helpful to get a quick reminder of some basic Matlab concepts. A great way to do this is through an instructional video that is provided with Matlab 7. This video can be accessed in Matlab with the command: >> playbackdemo( desktop ) or by going to Matlab s Start menu (not to be confused with Windows Start menu), and selecting Demos Desktop Tools and Development Environment Desktop and Command Window. Interactive plot tools New in Matlab 7 is an extensive set of interactive plot tools. With these tools it is possible to create most plots without using m-commands directly. The best introduction to these tools is given in an instructional video that is provided with Matlab 7. You can access this video in Matlab with the command: >> playbackdemo( PlotTools_viewlet_swf ) or by going to Matlab s Start menu and selecting Demos Graphics Interactive plot creation. Creating plots with m-commands The interactive plot tools include the option to generate m-commands for the interactively created plots. Those m-commands can be saved in a file that can be used later to recreate the plots. At that time, similar plots can be created using different data. M-commands are often used by experienced Matlab users to create figures, because they provide a quick, easy and reproducible way of generating figures. For this part of the course, the following m-commands are the most important for creating figures. stem This command creates a discrete sequence or stem plot. stem(y) plots the data sequence y as stems from the x-axis, terminated with circles for the data value. stem(x,y) plots the data sequence y at the values specified in x. Examples:.5 >> y = [ ]; >> stem(y);.5 3 4 5 6

SPHSC 53 Speech Signal Processing UW Summer 6.5 >> x = -:3; >> y = [ ]; >> stem(x,y);.5 - - 3 The stem command allows optional parameters to specify the color and style of the stem lines and stem markers, see help stem for details. plot This command produces a linear plot. plot(y) plots the vector y against its index. plot(x,y) plots vector y versus vector x. The line type, plot symbol and color may be specified in a third optional parameter, and multiple linear plots may be combined in a single command, such as plot(x,y,x,z). More information about this can be found by typing help plot in the Matlab command window. An advanced use of the plot command is shown in the example below. - >> x = -:; >> y = [ - -]; >> x = -:6; >> y = cos(*pi*x/7); >> plot(x,y, :ob,x,y, -xr ); - - 4 6 hold The hold command sets, clears or toggles the hold state of the current axes. When an axes is created (by using a plot or stem command for example), its hold state is set to off. Subsequent plot or stem commands will erase previous plots in the axes before drawing new plots. The hold on command can be used to turn the hold state to on, so that plots can be combined. hold off turns the hold state off, and hold by itself toggles the hold state of the current axes. For example, instead of the command >> plot(x,y,, :ob,x,y, -xr ); in the example above, we could have used the commands >> plot(x,y, :ob ); >> hold on >> plot(x,y, -xr ); to get the same effect.

SPHSC 53 Speech Signal Processing UW Summer 6 xlabel, ylabel, title These commands respectively add text beside the x-axis, y-axis or above the current axes. Their use is illustrated in the example below. Amplitude.5.5 -.5 Two signals (continued) >> xlabel( Index (n) ); >> ylabel( Amplitude ); >> title( Two signals ); - -.5 - - 4 6 Index (n) legend The legend displays a legend for the current axes. legend(string, string, string3,...) puts a legend on the current plot using the specified strings as labels. The example below shows how to add a legend to the plot from the previous example. The labels must be specified in the order that the plots were made..5 Two signals Line Sinus (continued) >> legend( Line, Sinus );.5 Amplitude -.5 - -.5 - - 4 6 Index (n) subplot The subplot command creates axes in tiled positions. subplot(r,c,i) breaks the figure window up in r by c axes, and selects the i-th axes for the current plot. The axes are numbered left to right, top to bottom. For example, to create a by 3 matrix of axes, and access each of them in turn, you would need the following commands: >> subplot(,3,) >> subplot(,3,) >> subplot(,3,3) >> subplot(,3,4) >> subplot(,3,5) >> subplot(,3,6) 3

SPHSC 53 Speech Signal Processing UW Summer 6 In the example below, the subplot command has been used to plot the two signals from the previous example in separate axes. subplot(,,) (continued) - - - - subplot(,,) >> subplot(,,); >> plot(x,y, :ob ); >> subplot(,,); >> plot(x,y, -xr );.5 -.5 - - 3 4 5 6 figure, clf, cla, close The figure, clf, cla and close commands manipulate figures and axes. The figure command, without any parameters, creates a new figure window and makes it the current window for new plots. figure(n) creates figure window n if it didn t exist and makes it the current window for new plots. The clf command clears the current figure, erasing all axes in it. To clear a specific figure, use a combination of figure(n), clf. The cla command clears only the current axes, erasing all plots, legends, etc. in the axes. To clear a specific axes, use a combination of figure(n), subplot(r,c,i), cla. The close command closes the current figure, and close(n) closes figure n. A note on current figures and axes: in Matlab, the current figure is the figure window that was selected last, either by a mouse click anywhere in the window, or by selecting it with the figure command. Similarly, the current axes is the axes that was selected last, either by a mouse click anywhere in the axes, or by selecting it with the subplot command. In-class exercises Exercise. Basic signals: impulses [from McClellan, ex.., page 3] The simplest signal is the (shifted) impulse sequence n= n δ[ n n ] = n n To create an impulse in Matlab, we must decide how much of the signal is of interest. For reasons we will see later, we are often interested in a number of points starting at n=. For example, we might want to see 3 points starting at n=, in which case the following Matlab code will create an impulse imp: >> n = :9; >> imp = zeros(size(n)); >> imp() = ; 4

SPHSC 53 Speech Signal Processing UW Summer 6 Notice in the code above that the n= index must be referred to as imp(), due to Matlab s indexing scheme which starts at. Instead of the third command above, a more advanced way of setting the point n= to is >> imp(n==) = ; This uses a Matlab technique called logical indexing to select which element of the imp vector to set to. In essence, this statement says: wherever the vector n equals, put a at the same location in the imp vector. Vectors n and imp must be of the same length for this to work. Given this background information and the introduction to the (interactive) plot tools of Matlab, generate and plot the following sequences. In each case, the horizontal (n) axis should extend only over the range indicated and should be labeled accordingly. Each sequence should be displayed as a discrete-time signal using stem. a. x [ n ] =.9 δ [ n 5], for n b. x [ n ] =.8 δ [ n ], for -5 n 5 c. x 3 [ n ] =.5 δ [ n 333], for 3 n 35 d. x 4 [ n ] = 4.5 δ [ n+ 7], for n Exercise. Basic signals: sinusoids [from McClellan, ex.., page 4] Another very basic signal is the (co)sine wave. In general, it takes three parameters to describe a real sinusoidal signal completely: amplitude (A), frequency ( ω ) and phase (φ ): xn [ ] = Acos( ω n+ φ) Generate and plot each of the following sequences. In each case, the horizontal (n) axis should extend only over the range indicated and should be labeled accordingly. Each sequence should be displayed as a sequence using stem. x[ n] = sin n, for n 5 π a. 7 x [ n] = sin n, for 5 n 5 π b. 7 c. x 3 [ n ] = sin(3 πn+ π / ), for n π x [ n] = cos( n), for n 5 d. 4 3 Explain why x [ ] 4 n is not a periodic sequence. Note: the stem command is most useful for short sequences, and in cases where you want to stress the discrete nature of the signal you re working with. In most practical cases, however, it is more convenient to use the plot command to display sequences. But beware that such a representation creates the illusion that you re dealing with a continuous signal, where in fact you re not. For example, if you use plot to display x 4 [ n ] in Exercise., it becomes almost impossible to tell that the sequence is not periodic. Exercise.3 Loading and analyzing a speech signal Get the file ex_3.wav from the class website, and save it in a local folder (suggested location C:\Temp\SPHSC53\ex_3.wav). The file contains the spoken word zero sampled at khz. Change the current directory in Matlab to the directory that contains the saved file. 5

SPHSC 53 Speech Signal Processing UW Summer 6 a. Load the ex_3.wav file into Matlab. You can either use Matlab s Import Wizard, by double-clicking on the filename in the current directory window, or use the wavread command (see help wavread for details). b. Plot the speech signal against its index by using the interactive tools or by using the plot command. c. Plot the speech signal as a function of time. Hint: you need to create a time vector t, and then plot the signal with plot(t,y). d. Determine the duration of the signal in seconds. It may be helpful to use the figure s zoom, pan and data cursor tools. Voiced speech, such as vowels, is characterized by a series of high-energy peaks in the speech signal. Those peaks are created by the repeated opening and closing of the vocal chords. e. Make a rough estimate of the distance in seconds between the peaks in the zero speech signal around t=. and t=.4 seconds, corresponding to the two vowels. Again, it may be helpful to use the figure s zoom, pan and data cursor tools. f. Convert the measured distances in seconds from part e into an estimate of the fundamental frequency (in Hz) of the speech signal around t=. and t=.4 seconds. 6