Full Download Anywhere anytime signals and systems laboratory from MATLAB to smartphones Second Edition Adrian Duran PDF DOCX
Full Download Anywhere anytime signals and systems laboratory from MATLAB to smartphones Second Edition Adrian Duran PDF DOCX
com
https://textbookfull.com/product/anywhere-anytime-signals-
and-systems-laboratory-from-matlab-to-smartphones-second-
edition-adrian-duran/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/continuous-signals-and-systems-with-
matlab-3rd-edition-taan-s-elali/
textboxfull.com
https://textbookfull.com/product/signals-and-systems-analysis-using-
transform-methods-and-matlab-third-edition-michael-j-roberts/
textboxfull.com
https://textbookfull.com/product/linear-systems-and-signals-b-p-lathi/
textboxfull.com
https://textbookfull.com/product/circuits-signals-and-systems-for-
bioengineers-3rd-edition-john-semmlow/
textboxfull.com
Graphene technology from laboratory to fabrication 1st
Edition Nazarpour
https://textbookfull.com/product/graphene-technology-from-laboratory-
to-fabrication-1st-edition-nazarpour/
textboxfull.com
https://textbookfull.com/product/multisensory-perception-from-
laboratory-to-clinic-krish-sathian/
textboxfull.com
https://textbookfull.com/product/polymyxin-antibiotics-from-
laboratory-bench-to-bedside-jian-li/
textboxfull.com
https://textbookfull.com/product/organic-and-carbon-gels-from-
laboratory-synthesis-to-applications-ana-arenillas/
textboxfull.com
https://textbookfull.com/product/seniors-edition-smartphones-tablets-
editors/
textboxfull.com
Anywhere-Anytime
Signals and Systems Laboratory
From MATLAB to Smartphones
Second Edition
Synthesis Lectures on Signal
Processing
Editor
José Moura, Carnegie Mellon University
Synthesis Lectures in Signal Processing publishes 80- to 150-page books on topics of interest to
signal processing engineers and researchers. The Lectures exploit in detail a focused topic. They can
be at different levels of exposition-from a basic introductory tutorial to an advanced
monograph-depending on the subject and the goals of the author. Over time, the Lectures will
provide a comprehensive treatment of signal processing. Because of its format, the Lectures will
also provide current coverage of signal processing, and existing Lectures will be updated by authors
when justified.
Lectures in Signal Processing are open to all relevant areas in signal processing. They will cover
theory and theoretical methods, algorithms, performance analysis, and applications. Some Lectures
will provide a new look at a well established area or problem, while others will venture into a brand
new topic in signal processing. By careful reviewing the manuscripts we will strive for quality both
in the Lectures’ contents and exposition.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in
any form or by any means—electronic, mechanical, photocopy, recording, or any other except for brief quotations
in printed reviews, without the prior permission of the publisher.
Anywhere-Anytime Signals and Systems Laboratory: From MATLAB to Smartphones, Second Edition
Nasser Kehtarnavaz, Fatemeh Saki, and Adrian Duran
www.morganclaypool.com
DOI 10.2200/S00879ED2V01Y201810SPR015
Lecture #15
Series Editor: José Moura, Carnegie Mellon University
Series ISSN
Print 1932-1236 Electronic 1932-1694
Anywhere-Anytime
Signals and Systems Laboratory
From MATLAB to Smartphones
Second Edition
M
&C Morgan & cLaypool publishers
ABSTRACT
A typical undergraduate electrical engineering curriculum incorporates a signals and systems
course. The widely used approach for the laboratory component of such courses involves the
utilization of MATLAB to implement signals and systems concepts. This book presents a newly
developed laboratory paradigm where MATLAB codes are made to run on smartphones, which
most students already possess. This smartphone-based approach enables an anywhere-anytime
platform for students to conduct signals and systems experiments. This book covers the labora-
tory experiments that are normally covered in signals and systems courses and discusses how to
run MATLAB codes for these experiments on both Android and iOS smartphones, thus en-
abling a truly mobile laboratory environment for students to learn the implementation aspects
of signals and systems concepts.
A zipped file of the codes discussed in the book can be acquired via the website http://si
tes.fastspring.com/bookcodes/product/SignalsSystemsBookcodesSecondEdition.
KEYWORDS
smartphone-based signals and systems laboratory; anywhere-anytime platform for
signals and system courses; from MATLAB to smartphones
vii
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
1 Introduction to MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Starting MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Arithmetic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.2 Vector Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.3 Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.1.4 Array Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.1.5 Allocating Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1.6 Special Characters and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1.7 Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.1.8 Programming in MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.1.9 Sound Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.1.10 Loading and Saving Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.1.11 Reading Wave and Image Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.1.12 Signal Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.2 MATLAB Programming Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.2.1 Signal Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.2.2 Generating a Periodic Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.3 Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
xi
Preface
A typical undergraduate electrical engineering curriculum incorporates a signals and systems
course where students normally first encounter signal processing concepts of convolution,
Fourier series, Fourier transform, and discrete Fourier transform. For the laboratory component
of such courses, the conventional approach has involved a laboratory environment consisting of
computers running MATLAB codes. There exist a number of lab textbooks or manuals for the
laboratory component of signals and systems courses based on MATLAB, e.g., An Interactive
Approach to Signals and Systems Laboratory by Kehtarnavaz, Loizou, and Rahman; Signals and
Systems Laboratory with MATLAB by Palamides and Veloni; Signals and Systems: A Primer with
MATLAB by Sadiku and Ali; and Signals and Systems by Mitra.
The motivation for writing this lab textbook or manual has been to provide an alternative
laboratory approach to the above conventional laboratory approach by using smartphones as a
truly mobile anywhere-anytime platform for students to run signals and systems codes written
in MATLAB on smartphones. This approach eases the requirement of using a dedicated lab-
oratory room for signals and systems courses and allows students to use their own laptop and
smartphones as the laboratory platform to learn the implementation aspects of signals and sys-
tems concepts. It is worth stating that this book is only meant as an accompanying lab book to
signals and systems textbooks and is not meant to be used as a substitute for these textbooks.
The challenge in developing this alternative approach has been to limit the programming
language required from students to MATLAB and not requiring them to know any other pro-
gramming language. MATLAB is extensively used in engineering departments and students are
often expected to use it for various courses they take during their undergraduate studies.
The above challenge is met here by using the smartphone software tools that are publicly
available. The software development environments of smartphones (both Android and iOS) are
free of charge and students can download and place them on their own laptops to be able to
run signals and systems algorithms written in MATLAB on their own smartphones. In this
lecture series book, we have developed the software shells that allow students to take MATLAB
codes written on a laptop and run them on their own smartphones as apps. In the first edition
of the book, the implementation was done on Android smartphones. In this second edition, in
addition to Android smartphones, the implementation is done on iOS smartphones.
The book chapters correspond to the following labs for a semester-long lab course consid-
ering that a typical signals and systems laboratory component includes labs 4–7: (1) introduc-
tion to MATLAB programming; (2) smartphone development tools (both Andorid and iOS);
(3) use of MATLAB Coder to generate C codes from MATLAB and how to run C codes
xii PREFACE
on smartphones as apps; (4) linear time-invariant systems and convolution; (5) Fourier series;
(6) continuous-time Fourier transform; and (7) digital signals and discrete Fourier transform.
Note that a zipped file of all the codes discussed in the book can be acquired from
the website http://sites.fastspring.com/bookcodes/product/SignalsSystemsBookc
odesSecondEdition.
As a final note, we wish to acknowledge Erik Jonsson School of Engineering and Com-
puter Science at the University of Texas at Dallas for the support we received while writing this
second edition.
CHAPTER 1
Introduction to MATLAB
MATLAB is a programming environment that is widely used to solve engineering problems.
There are many online references on MATLAB that one can read to become familiar with this
programming environment. This chapter is only meant to provide an overview or a brief intro-
duction to MATLAB. Screenshots are used to show the steps to be taken and configuration
options to set when using the Windows operating system.
+ addition
- subtraction
2 1. INTRODUCTION TO MATLAB
Workspace:
View variables that
are created and
stored during a
MATLAB session
Command History:
View or run
previously executed
functions
* multiplication
/ division (for matrices, it also means inversion)
>> a=1.2;
>> b=2.3;
>> c=4.5;
>> d=4;
>> a^3+sqrt(b*d)-4*c
ans =
-13.2388
Note the semicolon after each variable assignment. If the semicolon is omitted, the interpreter
echoes back the variable value.
x: y D Œx1 y1 ; x2 y2 ; :::; xn yn
x1 x2 xn
x:=y D ; ; :::;
y1 y2 yn
x: ^ p D Œx1 p ; x2 p ; :::; xn p :
Considering that the boldfacing of vectors/matrices are not used in .m files, in the notation
adopted in this book, no boldfacing of vectors/matrices is shown to retain notation consistency
with .m files.
The arithmetic operators C and can be used to add or subtract matrices, vectors, or
scalars. Vectors denote 1-dimensional arrays and matrices denote multi-dimensional arrays. For
example:
6 1. INTRODUCTION TO MATLAB
>> x=[1,3,4]
>> y=[4,5,6]
>> x+y
ans=
5 8 10
In this example, the operator C adds the elements of the vectors x and y, element by
element, assuming that the two vectors have the same dimension, in this case, or 1 3 one row
with three columns. An error occurs if one attempts to add vectors having different dimensions.
The same applies for matrices.
P
To compute the dot product of two vectors (in other words, xi yi ), use the multiplication
i
operator '*' as follows:
>> x*y'
ans =
43
Note the single quote after y denotes the transpose of a vector or a matrix.
An element-by-element multiplication of two vectors (or two arrays) is computed by the
following operator:
>> x .* y
ans =
4 15 24
This notation creates a vector starting from 1–6, in steps of 1. If a vector from 1–6 in steps of 2
is desired, then type:
>> x=1:2:6
ans =
1 3 5
One can easily extract numbers in a vector. To concatenate an array, the example below
shows how to use the operator '[ ]' :
>> x=[1:3 4 6 100:110]
>> y=zeros(100,1);
>> y(30)
ans =
0
The function zeros(n,m) creates an nm matrix with all 0 elements. One can allocate memory
for 2-dimensional arrays (matrices) in a similar fashion. The command or function
>> y=zeros(4,5)
defines a 4 by 5 matrix.
Similar to the command zeros , the command ones can be used to define a vector
containing all ones. For example,
>> y=ones(1,5)
ans=
1 1 1 1 1
>> x=1:10;
>> length(x)
ans =
10
The function find returns the indices of a vector that are non-zero. For example,
I = find(x>4) finds all the indices of x greater than 4. Thus, for the above example:
>> find(x>4)
ans =
5 6 7 8 9 10
1.1. STARTING MATLAB 9
Table 1.1: Some widely used special characters used in m-files
Symbol Meaning
pi π (3.14.....)
^ indicates power (for example, 3^2 = 9)
NaN not-a-number, obtained when encountering undefined operations, such as 0/0
Inf represents +∞
; indicates the end of a row in a matrix; also used to suppress printing on the screen
(echo off )
% comments—anything to the right of % is ignored by the .m file interpreter and is
considered to be comments
' denotes transpose of a vector or a matrix; also used to define strings, for example,
str1 = 'DSP'
… denotes continuation; three or more periods at the end of a line continue current
function to next line
Function Meaning
sqrt indicates square root, for example, sqrt(4) = 2
abs absolute value |.|, for example, abs(-3) = 3
length length(x) gives the dimension of the array x
sum finds sum of the elements of a vector
find finds indices of nonzero
• if statements
• switch statements
• for loops
• while loops
• break statements
10 1. INTRODUCTION TO MATLAB
The constructs if , for , switch , and while need to terminate with an end state-
ment. Examples are provided below:
if
>> x=-3;
if x>0
str='positive'
elseif x<0
str='negative'
elseif x== 0
str='zero'
else
str='error'
end
The above code computes the sum of all the numbers from 1–10.
break
With the break statement, one can exit early from a for or a while loop. For example,
>> x=-10;
while x<0
x=x+2;
if x == -2
break;
1.1. STARTING MATLAB 11
end
end
Some of the supported relational and logical operators are listed in Tables 1.3 and 1.4.
Symbol Meaning
<= less than equal
< less than
>= greater than equal
> greater than
== equal
~= not equal
Symbol Meaning
& AND
| OR
~ NOT
Figure 1.6: m-file script interactive window after running the program average.
>> t=0:1/8000:1;
>> x=cos(2*pi*400*t);
>> sound(x,8000);
The function randn generates Gaussian noise with zero mean and unit variance.
The vector x gets loaded in memory. To see memory contents, use the command whos :
>> whos
Variable Dimension Type
x 1x8000 double array
The command whos gives a list of all the variables currently in memory, along with their
dimensions and data type. In the above example, x contains 8,000 samples.
To clear up memory after loading a file, type clear all when done. This is important
because, if one does not clear all the variables, conflicts can occur with other codes using the
same variables.
This command reads a .wav file specified by the string filename and returns the sampled data
in y with the sampling rate of Fs (in Hertz).
14 1. INTRODUCTION TO MATLAB
To read an image file, use the following command:
>> [y]=imread('filename')
This command reads a grayscale or color image from the string filename and returns the
image data in the array y.
>> plot(x,y)
This function creates a 2-D line plot of the data in y vs. corresponding x values.
2 2
0 1 2 3 t 0 1 2 3 t
To simulate this signal, use the MATLAB functions ones and zeros . The signal value is zero
during the first second, which means the first 1,000 samples are zero. This portion of the signal
is simulated with the function zeros(1,1000) . In the next second (next 1,000 samples), the
signal value is 2, and this portion is simulated by the function 2*ones(1,1000) . Finally, the
third portion of the signal is simulated by the function zeros(1,1000) . In other words, the
entire duration of the signal is simulated by the following .m file function:
A linearly increasing or decreasing vector can thus be used to represent the linear portions.
The time vectors for the three portions or segments of the signal are 0:dt:1-dt , 1:dt:2-dt ,
and 2:dt:3-dt . The first segment is a linear function corresponding to a time vector with a
slope of 2; the second segment is a linear function corresponding to a time vector with a slope
of 2 and an offset of 4; and the third segment is simply a constant vector of zeros. In other
words, the entire duration of the signal for any value of dt can be simulated by the following .m
file function:
x2=[2*(0:dt:(1-dt)) -2*(1:dt:(2-dt))+4 zeros(1,1/dt)]
Figures 1.8 and 1.9 show the MATLAB code and the plot of the above signal gener-
ation, respectively. Signals can be displayed using the function plot(t,data) . For proper
plotting, first the correct t vector needs to be generated. Here this is done by using the function
linspace :
>> t=linspace(0,E,N)
16 1. INTRODUCTION TO MATLAB
This function generates a vector t of N points linearly spaced between and including 0 and
E , where N is equal to E/dt .
1.2. MATLAB PROGRAMMING EXAMPLES 17
1.2.2 GENERATING A PERIODIC SIGNAL
In this example, a simple periodic signal is generated. This example involves generating a periodic
signal in textual mode and displaying it graphically. The shape of the signal ( sin , square ,
triangle , or sawtooth ) can be modified, as well as its frequency and amplitude, by using
appropriate control parameters. The MATLAB code and the plots generated by it are shown in
Figures 1.10 and 1.11, respectively.
Now consider an m-file code to generate four types of waveforms using the functions
sin , square , and sawtooth . To change the amplitude and frequency of the waveforms,
two control parameters named Amplitude ( A ) and Frequency ( f ) are used. Waveform Type
( w ) is another parameter used for controlling the waveform type. With this control parameter,
one can select from multiple inputs. Finally, the waveforms are displayed by using the function
plot .
—D’r mot nou moar op hoop set hee? wá’ d’r stoan,
stoan d’r dan.
—Aa’s die hoop daan is, sal t’met tait sain Kees, zei
kalm Dirk, voortharkend rond z’n broer, die even
angstig keek of z’n hooge hoop ook helde.
[Inhoud]
III.
[Inhoud]
IV.
—Nou, ikke van drie tut naige.… main waif hep vinte
waist.… moar sai is d’r tut op haide, f’rdorie nòg nie.…
hep jai d’r nie sien?.… hep puur al twai kair an de
hoafe waist.… lag d’r aêrs al langerst in.… ikke si’
puur te wachte mi’ de sloap in main lampies.…
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com