1. Trang chủ
  2. » Luận Văn - Báo Cáo

Digital Signal Processing Lab Student's Manual.pdf

49 0 0
Tài liệu được quét OCR, nội dung có thể không chính xác
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Digital Signal Processing Lab
Trường học Ton Duc Thang University
Chuyên ngành Digital Signal Processing
Thể loại Student's Manual
Năm xuất bản 2016
Định dạng
Số trang 49
Dung lượng 4,02 MB

Nội dung

1.1.2.2 Creating a new project In this lab, you will create a project with the Code Composer Studio™ IDE and add source code files and libraries to the project.. There are the following

Trang 1

DAI HOC TON BUC THANG

Faculty of Electrical and Electronics Engineering

DIGITAL SIGNAL PROCESSING LAB

STUDENT'S MANUAL

TON DUC THANG UNIVERSITY - 2016

Trang 2

LAB1 INTRODUCTION TO TMS320C6713 DSK AND CODE COMPOSER STUDIO 3

1.1.1 TMS320C6713 DSK nh nh HH Hà Hà HH HH Tà Hà HH HH TH Ho HH Hy 3 1.1.2 Getting Familiar with Code Composer Studio |DE ch nh HH HH nh Ho tk Hà 6 1.2 GENERATION OF SINUSOID USING THE TMS320C6713 DSP STARTER KIT (DSKI ào nhe 13

1.2.2 Recall background of sampling nh nh nh HH Hà Hà KH HH nâu 13 1.2.3 Lab procedure nh nh nh HH nh Hà HH HH KH tk KH KH Ki ty 14 LAB2 DISCRETE AND CONTINOUS TIME SIGNAL ch nh HH hà Hà Hay 19

2.2.1 Starting Matlab and getting help tte eee tenet enti TH HH TH Ho HH hờ 19 2.2.2 Matrices and operations ánh nh nh Hà Hàng Hà KHE HH tk Hit 19 2.23 Matlab scripts and funcfiOnS ch nh nh TH han Hà Hà KHE HH KH hy 20 2.2.4 Continuous time vs Discrete tiM@ ii rn iri Hà HH HH Hà HH th Ho 20 2.2.5 Processing Of speech signal nh nh nh nh HH KH HH hy 22

LAB3 FINITE IMPULSE RESPONSE (FIR) FILTERING nh HH HH gen 24

3.2.1 Design parameter determinatiOn ch nh HH hà HH HH HH KH kh tết 25 3.2.2 Filter coefficlent calculafion iinet 26 LAB 4 INFINITE IMPULSE RESPONSE (IIR) FILTERING nh HH HH Hà Ho aa 33

4.2 LAB PROCEDURE nh nh TH HH Hà HH HH KH TH H TH HH TT HH TH TH HH 34 4.21 'Transposed realiza†iOn ác nh nh HH HH HH HH kh KH tk KH KH tk KH kh 34 4.2.2 Feedback system EE HH rr HH KH KH TH KH 36 LAB5 IMPLEMENTATION OF FAST FOURIER TRANSFORM (FFT) ON DSK cà: 40

5.1.1 Discrete Fourier Transform ác nh nh HH HH HH Hà Tà Hà He TH kh HH Hà Ho hay 40 5.1.2 A fast Fourier transform algorithim LH HH HH kh kh KH kh 41 5.2 IMPLEMENTING AN FFT ALGORITHM ON THE C6713 DSK án SE nh nh nh nà HH HH HH ghe 43 5.2.1 The bit reversing algorithm ch HH HH HH Hà KH KH tk ki 43 5.2.2 Implementing the Factored Buff©rfly ch nh nh nh Hà Hà HH Hà Hg HH tt 45

Trang 3

Week 1 - 2 Introduction to the lab

Lab 1 — 1.1 Intro to DSK and code composer studio Lab 1 — 1.2 Generation of sinusoid using DSK Lab 2 — Digital process of continuous time signal Week 3 Lab 3 — FIR filtering

Week 4 Lab 4 — IIR filtering

Week 5 Lab 5 — FFT

Trang 4

LAB 1 INTRODUCTION TO TMS320C6713 DSK AND CODE

Other hardware features of the TMS320C6713 DSK board include:

e Embedded JTAG support via USB

e High-quality 24-bit stereo codec

e Four 3.5mm audio jacks for microphone, line in, speaker and line out

e 512K words of Flash and 16 MB SDRAM

e Expansion port connector for plug-in modules

e On-board standard IEEE JTAG interface

e +5V universal power supply

Power USB DIP LEDs Reset Config External Hurricane

Figure 1-1 TMS320C6713 DSP Starter KIT

Page 3 of 49

Trang 5

Figure 1-2 TMS320C6713 DSK block diagram

The C6713 processor has 256 KB of internal memory, and can potentially address 4GB of external memory The DSK board includes a 16MB SDRAM memory and a 512KB Flash ROM It has an on- board 16-bit audio stereo codec (the Texas Instruments AlIC23B) that serves both as an A/D anda D/A converter There are four 3.5 mm audio jacks for microphone and stereo line input, and speaker and head-phone outputs The AlIC23 codec can be programmed to sample audio inputs at the following sampling rates: fs = 8, 16, 24, 32, 44.1, 48, 96 kHz

The ADC part of the codec is implemented as a multi-bit third-order noise-shaping delta-sigma converter that allows a variety of oversampling ratios that can realize the above choices of fs The corresponding oversampling decimation filters act as anti-aliasing prefilters that limit the spectrum of the input analog signals effectively to the Nyquist interval [-fs /2, fs /2] The DAC part is similarly implemented as a multi-bit second-order noise-shaping delta-sigma converter whose oversampling interpolation filters act as almost ideal reconstruction filters with the Nyquist interval as their passband The DSK also has four user-programmable DIP switches and four LEDs that can be used to control and monitor programs running on the DSP

All features of the DSK are managed by the CCS, which is a complete integrated development environment (IDE) that includes an optimizing C/C++ compiler, assembler, linker, debugger, and program loader The CCS communicates with the DSK via a USB connection to a PC In addition to facilitating all programming aspects of the C6713 DSP, the CCS can also read signals stored on the DSP’s memory, or the SDRAM, and plot them in the time or frequency domains

The following block diagram depicts the overall operations involved in all of the hardware experiments in the DSP lab Processing is interrupt-driven at the sampling rate fs, as explained below

Page 4 of 49

Trang 6

At each sampling instant, the codec combines the two 16-bit left/right samples into a single 32-bit unsigned integer word (an unsigned int, or Uint32 data type in C), and ships it over to a 32-bit receive- register of the multichannel buffered serial port (McBSP) of the C6713 processor, and then issues an interrupt to the processor

KG DOUT | 5 ADC lant ~$==i====| MIC IN a

CUŒ1 DSP Fam — BCU< LRCOUT i en une

Clearly, all processing operations during the execution of the ISR must be completed in the time interval between samples, that is, T = 1/fs For example, if fs = 44.1 kHz, then, T = 1/fs = 22.68 psec With an instruction cycle time of Tc = 4.44 nanoseconds, this allows T/Tc = 5108 cycles to be executed during each sampling instant, or, up to 8x5108 = 40864 instructions, or half of that per channel

Page 5 of 49

Trang 7

RECAP: C6713 DSK OVERVIEW

e 225 MHz TMS320C67 13 floating point DSP

e AIC23 stereo codec (ADC and DAC)

© Ideal for audio applications

o 8-96 KHz sample rates

e Memory

o 16 MB dynamic RAM

o 512 KB nonvolatile FLASH memory

e General purpose I/O

o 4LEDs

o 4 DIP switches

e USB interface to PC

How to know if your DSK working?

>DSK Power On Self Test

1 Power up DSK and watch LEDs

2 Power On Self Test (POST) program stored in FLASH memory automatically executes POST takes about 10 to 15 seconds to complete

3 All DSK subsystems are automatically tested

4 During POST, a 1KHz sinusoid is output from the AlIC23 codec for 1 second Listen with headphones or observe on oscilloscope

5 If POST is successful, all four LEDs (D7 >D10) blink 3 times and then they remain on 1.1.2 Getting Familiar with Code Composer Studio IDE

1.1.2.1 Connecting with DSK

To connect DSK with CCS, do the following steps:

1 Power up the DSK, then wait for POST to complete

2 Connect the USB cable from PC to DSK

4 >

3 Launch CCS me , CCS will load and wait for your input

4 Connect to DSK

Trang 8

€ 1C6713 DSK/CPU_1 - C621x - Code Composer Studio - Not Connect

File Edit Yiew Project Debug GEL Option Profile Tools DSP/BIOS Windo

The target is now connected

Reset Emulator Ctrl+Shift+R

1.1.2.2 Creating a new project

In this lab, you will create a project with the Code Composer Studio™ IDE and add source code files and libraries to the project There are the following types of files:

ib This library provides runtime support for the target DSP chip

This file contains source code that provides the main functionality of this project This file declares the buffer C-structure as well as define any required constants -pjt This file contains all of your project build and configuration options

.asm_ This file contains assembly instructions

.cmd_ This file maps sections to memory

To create a new project, do the following steps:

1 Project >New

Trang 9

Project Type: | Executable [.out] |

Write your new C code: File > New > Source File (type in your new C code)

1 Try “helloworld” program:

Save the new C code in your project directory, make sure it has a c extension

Add the new C code to the project: Project > Add file to project

Add the required support files to the project: Project > Add file to project

1 C©6713dsk.cmd_ - linker command file

2 Rts6700.lib - run-time support library functions

Add the optional support files to the project:

1 Vectors_poll.asm or vectors_intrasm - use to set up interrupt vectors

2 Dsk6713bsl.lib - DSK board support library functions — useful for interfacing to the codec, DIP switches, and LEDs

3 Csl6713.lib - chip support library functions

Set up the build options for C6713: Project > Build options

1 Make sure target version is C671x

2 Make sure Opt Level is “None”

Trang 10

Build Options for helloworld pjt (Debug) WBS

General Compiler | Linker | Link Order |

-g -fr''$(Proi_dir)\D ebug" -d""_ DEBUG" -mv6710

Category: Basic

[Basic Advanced Target Version: ÍCB71x (-mv6710) ~| =e

Feedback Generate Debug Info: | Full Symbolic Debug [-g) xi

Assombly Opt Speed vs Size: [Speed Most Critical [no -ms)} vị

9 Build the project: Project > Build

10 After successfully build the project, load it to the DSK: File > Load program

TẾ (C6713 DSKICPU_1 - C671x - Code Compose Biiae

Select the out file in the project\Debug directory Program is sent to DSK

Remember to select the out file

Page 9 of 49

Trang 11

To build and run the program, follow these steps:

1

2

Choose Project > Rebuild All or click thee (Rebuild All) toolbar button The

program recompiles, reassembles, and relinks all the files in the project The Build frame at the bottom of the window displays messages about this process

By default, the out file is built into a debug directory located under your current project folder You can change this location by selecting a different one from the tool bar

x||Debug x lỗi #

Choose File > Load Program Select the program you just rebuilt, Volume1.out, and click Open (It should be in the C:\CCStudio_v3.10\myprojects\volume1\Debug)\ folder unless you set up your project directory elsewhere.) CCStudio loads the program onto the target DSP and opens a Disassembly window that shows the disassembled instructions that make up the program (A Stdout tab may open at the bottom of the window to show any output the program sends to stdout.)

In the displayed disassembly window, click on an assembly instruction in the mixed-mode window (Click on the actual instruction, not the address of the instruction or the fields passed

to the instruction.) Press the F1 key to search for help on the disassembled instruction This is

a good way to get help on an unfamiliar instruction

Choose Debug > Go Main to begin execution from the main function

Choose Debug > Run, or click th (Run) toolbar button The text "volume example started” should appear in the Stdout tab of the message window on the bottom of the CCStudio™ screen

Choose Debug > Halt to quit running the program

From the View menu, choose Mixed Source/ASM to un-check the menu item if it is checked

on This allows you to view c code without the assembly so you can accomplish the next task: Changing Program Options and Fixing Syntax errors

Trang 12

1.1.2.3 Other operations with CCS

1 To open an existing project: Project > Open

Choose a pjt file to open

2 Fixing the search path:

Project > Build options > [Compiler Tab] > [Preprocessor Category]

Build Options for Sine8_LED.pjt (Debug) we

General Compiler Linker | Link Order |

Assembly Undefine Symbol [-u):

Diagnostics [— Continue with Compilation (-ppa)

Add: C:\CCStudio_v3.1\C6000\dsk67 13\include to the search path

3 Fixing the problem of finding files during linking:

You will get the following message about compilation failure:

[Loop_store.c] "C:\CCStudio_v3.1\C6dg00Ncgtools\bin\cl6x" -g -q -fr'C:7 {[Linking ] "C:\CCStudio_v3.1\C6000Negtools\bin\cl6x" -@"Debug.1kf"

<Linking>

>> C:NDOCUME™ 1\drbNLOCALS” 1\TempNTI5643, line 21: error:

can't find input file 'DS5K6713bs1.1ib'

>> Compilation failure

Build Complete

This problem is caused by a bad path for the include library in the linker option

Project > Build options > linker tab

Trang 13

[Build Options for Loop store pjt(Debu) i07 Goreral| Comper LFEer | Link Order |

Sea Categony Basic

IV Suceress Barrer Ca]

I Exhoustively load Libraries |-x|

Libiany Search Path (il ——=—————

Indude Livanes [Ê.- J:t:c7001ib:DEKEZI3Sb:llb;esiE713lb

4 Fixing the memory model: Change the memory model to “data=far”

Project > Build options > [Compiler Tab] > [Advanced Category]

Build Options for Sine8_LED.pjt (Debug) 2 General Compiler | Linker | Link Order |

-g -s -fr’'C:\CCStudio NI ha LED\Debug"

f'C:\CCStudio_v3.1\C6000\dsk671 3\include" -d"CHIP_6713" -mv6710

~mem _I model dala-far

Category: , Advanced

Basic RTS Modifications: Defns No RTS Funes

Feedback Auto Inline Threshold (-oif | Files Assembh Endianness: T Little Endian ow

Parser Preprocessor Memory Models: Far (~mem_model: data=far) xi

Diagnostics RTS Calls: Fer Aggregate Alasng

Í” Interupt Thưeshold [-m): |

I~ Speculate Threshold (-mh} |

[~ Tum Off Software Pipelining (-mu) T~ Old 6400 Alignment Compatibility (-mb) [Tum Off Reorder of Associative Floating Pt Ops (-me)

I~ Use Function Subsections (-mo}

T~ Historic C Pointer to Const Alias Disambiguation (-ox)

LK] cancet_| Her _|

Trang 14

5 Suppress linker warning:

In the Advanced category, uncheck “warn about output section”

1.2 Generation of sinusoid using the TMS320C6713 DSP Starter Kit (DSK)

1.2.1 Lab objective

In this lab, you will familiarize yourself with DSK and Tl Code Composer Studio (CCS) by generating a sinusoid using the table look up method

1.2.2 Recall background of sampling

If a sine wave of frequency 1kHz with an amplitude of 1000 is sampled at the rate of 8kHz, you will the following periods:

e Period of sine wave = 1/1000 = 0.001 sec

e Sampling period =1/8000 = 0.000125 sec

Notice that during the singe period of the sine wave we will have 8 samples each separated at equally space time of 0.000125 sec

The sampled waveform is x = 1000 sin(2mn”

From this we can build up the table for the amplitude of the sine wave at value of n=0, 1, 2, 3,

4, 5, 6 & 7 to cover one period of the sine wave

Trang 15

1.2.3 Lab procedure

Step 1: Creating project

Connect the line out (using the audio jack) to an oscilloscope or speaker

Make sure that the DSK Board is connected to the Desktop Computer through the UBS port and that the dc power supply of 5v is connected to the DSK Board

Power up the desktop computer until the XP window is running Then switch on the dc power supply

to the DSK board

1 Launch CCS

2 Create project file name: Sinexp1.pjt

3 Add file sin8_buf.c to the project

The content of file sine8_buf.c:

Trang 16

10

1 =

12

Add supporting file to the project: file C6713dskinit.c

Click on the “+” symbol to the left of the Project Files window to check whether these two c files have been added to the project

Use the pull-down menu for Files of type, select ASM Source Files Double click on the assembly source file vectors_intr.asm (located in support folder) to add it to the project Use the pull-down menu for Files of type, select Linker Command File Double click on the file C6713dsk.cmd (located in support folder) to add it to the project

Use the pull-down menu for Files of type, select Object and Library Files Double click on the run-time support library file (located in C:\CCStudio_v3.1\c6000\cgtools\lib) rts6700.lib

to add it to the project

Use the pull-down menu for Files of type, select Object and Library Files Double click on the board support library (BSL) file (located in C:\CCStudio_v3.1\c6000\dsk67 1 3\lib)

dsk6713bsl.lib to add it to the project

Use the pull-down menu for Files of type, select Object and Library Files Double click on the chip support library (CSL) file (located in C:\CCStudio_v3.1\c6000\csl\lib) csl6713.lib to add

it to the project

Verify from the File window that the project(.pjt) file, linker command file (.cmd), the three library (lib) files, the two C source (.c) files and the assembly (.asm) file have been added to the project

Select Project > Scan All File Dependencies This will add/include the header files c67 13dskinit.h, along with several board and chip support header files included with CCS Step 2: CCS build options

1 Before you can successfully build your project, you need to specify the relevant options for the compiler and linker

a) Compiler Option:

Select Project Build Option

Select Compiler Tab Under the

Compiler Tab:

Select Basic under the Category sub window Select:

C671x(-mv6710) for Target Version

Trang 17

Full Symbolic Debug (-g) for Generate Debug Info Speed Most

Critical (no —ms) for Opt Speed vs Size None for Opt Level

None for Program Level Opt

Select Preprocessor under the Category sub window

For Include Search Path (-i): Type C:\CCStudio_v3.1\MyProjects\ Support\ For For Pre-Define Symbols(-d): Type CHIP_6713

For Undefine Symbol(-u): Leave blank

For Preprocessing: Select None

Select Advance under the Category sub window

For Memory Models: Select Far( mem_model:data=far)

b) Linker Option:-

Select Linker Tab

Under the Linker Tab: > Select Basic >For Stack Size(-stack): type 800

Step 3: Building Your Program

After you build your project, the include files appear in the Project View

Now that you have created a functional program, you can build it Use the Build All function the first time you build the project An output window will show the build process and status When the build is finished, the output window will display Build complete 0 errors, 0 warnings

The Rebuild All command is mainly used to rebuild the project when the project options or any files in the project have changed

(Project > Build All)

Step 4: Loading Your Program

Before loading, you need to select Debug > Connect

After the program has been built successfully, load the program by going to File > Load Program

By default, Code Composer Studio IDE will create a subdirectory called Debug within your project directory and store the out file in it Select sinesxp1.out and click Open to load the program (File > Load Program > Debug > sinexp1.out)

Note: Remember to reload the program by choosing File>Reload Program if you rebuild the project after making changes

Step 5: Running the Executable file sinexp1.out

Select Debug>Run or use the toolbar with the “running man” Connect a scope to the LINE OUT connector on the DSK Verify that a 1 KHz sinusoid is generated

Step 6: Plotting with CCS

Halt the DSK by selecting Debug Halt or the “stop running man” icon

The output buffer is continuously being updated every 256 points We can use the CCS to plot the current output data stored in the out_buffer

Select View> Graph >Time/Frequency Change the graph Property Dialog as follows:

Trang 18

Select Window > Tile Vertically

Trang 19

Assignment:

Now, it’s your turn Write a program to generate a cosine with frequency of 666.66 Hz Use the same sampling frequency of 8000Hz Verify your output result using LINE OUT, and plotting the generated cosine in both time and the frequency domains

Trang 20

LAB 2 DISCRETE AND CONTINOUS TIME SIGNAL

2.1 Objectives

The purpose of this lab is to illustrate the properties of continuous and discrete-time signals using digital computers and the Matlab software environment A continuous-time signal takes on a value at every point in time, whereas a discrete-time signal is only defined at integer values of the “time” variable However, while discrete-time signals can be easily stored and processed on a computer, it is impossible to store the values of a continuous-time signal for all points along a segment of the real line

In later labs, we will see that digital computers are actually restricted to the storage of quantized discrete- time signals Such signals are appropriately known as digital signals How then do we process continuous-time signals? In this lab, we will show that continuous time signals may be processed by first approximating them by discrete-time signals using a process known as sampling We will see that proper selection of the spacing between samples is crucial for an efficient and accurate approximation

of a continuous-time signal Excessively close spacing will lead to too much data, whereas excessively distant spacing will lead to a poor approximation of the continuous-time signal Sampling will be an important topic in future labs, but for now we will use sampling to approximately compute some simple attributes of both real and synthetic signals

2.2 MatLab review

2.2.1 Starting Matlab and getting help

You can start Matlab (version 7.0) on your workstation by typing the command matlab in a command window After starting up, you will get a Matlab window To get help on any specific command, such as “plot”, you can type the following help plot in the “Command Window” portion of the Matlab window You can do a keyword search for commands related to a topic by using the following look for topic You can get an interactive help window using the function helpdesk or by following the Help menu near the top of the Matlab window

2.2.2 Matrices and operations

Every element in Matlab is a matrix So, for example, the Matlab command

a=[123]

creates a matrix named “a” with dimensions of | < 3 The variable “a” is stored in what is called the Matlab workspace The operation

b=a.°

stores the transpose of “a” into the vector “b” In this case, “b” is a3 = 1 vector

Since each element in Matlab is a matrix, the operation

c=a'b computes the matrix product of “a” and “b” to generate a scalar value for “c” ofI4=Ix*x1+2x2+3

* 3

Trang 21

Often, you may want to apply an operation to each element of a vector For example, you many want to square each value of “a’”’ In this case, you may use the following command

c=a*a The dot before the * tells Matlab that the multiplication should be applied to each corresponding element

of “a” Therefore the * operation is not a matrix operation The dot convention works with many other Matlab commands such as divide /, and power * An error results if you try to perform element-wise operations on matrices that aren’t the same size Note also that while the operation a.’ performs a transpose on the matrix “a”, the operation a’ performs a conjugate transpose on “a” (transposes the matrix and conjugates each number in the matrix)

2.2.3 Matlab scripts and functions

Matlab has two methods for saving sequences of commands as standard files These two methods are called scripts and functions Scripts execute a sequence of Matlab commands just as if you typed them directly into the Matlab command window Functions differ from scripts because they take inputs and return outputs A script-file is a text file with the filename extension “.m” The file should contain

a sequence of Matlab commands The script-file can be run by typing its name at the Matlab prompt without the m extension This is equivalent to typing in the commands at the prompt Within the script- file, you can access variables you defined earlier in Matlab All variables in the script-file are global, i.e after the execution of the script-file, you can access its variables at the Matlab prompt

To create a function call “func”, you first create a file called “func.m” The first line of the file must

be

function output = func(input) where “input” designates the set of input variables, and “output” are your output variables The rest of the function file then contains the desired operations All variables in the function are local; that means the function cannot access Matlab workspace variables that you don’t pass as inputs After the execution

of the function, you cannot access internal variables of the function

2.2.4 Continuous time vs Discrete time

2.2.4.1 Display continuous time signal and discrete time signal in matlab

It is common to graph a discrete-time signal as dots in a Cartesian coordinate system This can be done

in the Matlab environment by using the stem command We will also use the subplot command to put multiple plots on a single figure Start Matlab on your workstation and type the following sequence of commands

Trang 22

y = sin(n/6);

subplot(3,1,1) stem(n,y) This plot shows the discrete-time signal formed by computing the values of the function sin(t/6) at points which are uniformly spaced at intervals of size 2 Notice that while sin(t/6) is a continuous-time function, the sampled version of the signal, sin(n/6), is a discrete-time function A digital computer cannot store all points of a continuous-time signal since this would require an infinite amount of memory It is, however, possible to plot a signal which looks like a continuous-time signal, by computing the value of the signal at closely spaced points in time, and then connecting the plotted points with lines The Matlab plot function may be used to generate such plots Use the following sequence of commands to generate two continuous-time plots of the signal sin(t/6)

n1 = 0:2:60:

z = sin(n1/6);

subplot(3,1,2) plot(n1,z)

n2 =0:10:60;

w =sin(n2/6);

subplot(3,1,3) plot(n2,w)

2.2.4.2 Numerical computation of continuous time signal

Background on Numerical Integration:

One common calculation on continuous-time signals is integration Figure 1 illustrates a method used for computing the widely used Riemann integral The Riemann integral approximates the area under a curve by breaking the region into many rectangles and summing their areas Each rectangle is chosen to have the same width At, and the height of each rectangle is the value of the function at the start of the rectangle’s interval

Trang 23

Figure 2-1 Illustration of the Riemann integral

To see the effects of using a different number of points to represent a continuous-time signal, write a Matlab function for numerically computing the integral of the function sin7(5t) over the interval [0, 2a] The syntax of the function should be | = integ1(N) where | is the result and N is the number of rectangles used to approximate the integral This function should use the sum command and it should not contain any for loops!

Note: Since Matlab is an interpreted language, for loops are relatively slow Therefore, we will avoid using loops whenever possible

Next write an m-file script that evaluates I(N) for 1 <N < 100, stores the result in a vector and plots the resulting vector as a function of N This m-file script may contain for loops Repeat this procedure for

a second function J=integ2(N) which numerically computes the integral of exp(t) on the interval [0, 1] 2.2.5 Processing of speech signal

Digital signal processing is widely used in speech processing for applications ranging from speech compression and transmission, to speech recognition and speaker identification

This exercise will introduce the process of reading and manipulating a speech signal

First download the speech audio file speech.au , and then do the following:

1 Use the auread command to load the file speech.au into Matlab

2 Plot the signal on the screen as if it were a continuous-time signal (i.e use the plot command) 2.2.6 Sampling

The word sampling refers to the conversion of a continuous-time signal into a discrete-time signal The signal is converted by taking its value, or sample, at uniformly spaced points in time The time between two consecutive samples is called the sampling period

For example, a sampling period of 0.1 seconds implies that the value of the signal is stored every 0.1 seconds Consider the signal f(t) = sin(2zt) We may form a discrete-time signal, x(n), by sampling this signal with a period of Ts In this case, x(n) = f(Tsn) = sin(2aTsn)

Use the stem command to plot the function f(Tsn) defined above for the following values of Ts and

Trang 24

Use the subplot command to put all the plots in a single figure, and scale the plots properly with the axis command

Ngày đăng: 04/10/2024, 14:58