PDF Anywhere Anytime Signals and Systems Laboratory From Matlab To Smartphones Second Edition Adrian Duran Ebook Full Chapter

Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

Anywhere anytime signals and systems

laboratory from MATLAB to


smartphones Second Edition Adrian
Duran
Visit to download the full and correct content document:
https://textbookfull.com/product/anywhere-anytime-signals-and-systems-laboratory-fr
om-matlab-to-smartphones-second-edition-adrian-duran/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Continuous signals and systems with MATLAB 3rd Edition


Taan S. Elali

https://textbookfull.com/product/continuous-signals-and-systems-
with-matlab-3rd-edition-taan-s-elali/

Signals and systems : analysis using transform methods


and MATLAB Third Edition Michael J. Roberts

https://textbookfull.com/product/signals-and-systems-analysis-
using-transform-methods-and-matlab-third-edition-michael-j-
roberts/

Linear Systems and Signals B. P. Lathi

https://textbookfull.com/product/linear-systems-and-signals-b-p-
lathi/

Circuits Signals and Systems for Bioengineers 3rd


Edition John Semmlow

https://textbookfull.com/product/circuits-signals-and-systems-
for-bioengineers-3rd-edition-john-semmlow/
Graphene technology from laboratory to fabrication 1st
Edition Nazarpour

https://textbookfull.com/product/graphene-technology-from-
laboratory-to-fabrication-1st-edition-nazarpour/

Multisensory Perception From Laboratory to Clinic Krish


Sathian

https://textbookfull.com/product/multisensory-perception-from-
laboratory-to-clinic-krish-sathian/

Polymyxin Antibiotics From Laboratory Bench to Bedside


Jian Li

https://textbookfull.com/product/polymyxin-antibiotics-from-
laboratory-bench-to-bedside-jian-li/

Organic and Carbon Gels From Laboratory Synthesis to


Applications Ana Arenillas

https://textbookfull.com/product/organic-and-carbon-gels-from-
laboratory-synthesis-to-applications-ana-arenillas/

Seniors Edition Smartphones Tablets Editors

https://textbookfull.com/product/seniors-edition-smartphones-
tablets-editors/
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.

Anywhere-Anytime Signals and Systems Laboratory: From MATLAB to Smartphones,


Second Edition
Nasser Kehtarnavaz, Fatemeh Saki, and Adrian Duran
2019

Anywhere-Anytime Signals and Systems Laboratory: from MATLAB to Smartphones


Nasser Kehtarnavaz and Fatemeh Saki
2017

Smartphone-Based Real-Time Digital Signal Processing


Nasser Kehtarnavaz, Shane Parris, and Abhishek Sehgal
2015

An Introduction to Kalman Filtering with MATLAB Examples


Narayan Kovvali, Mahesh Banavar, and Andreas Spanias
2013

Sequential Monte Carlo Methods for Nonlinear Discrete-Time Filtering


Marcelo G.S. Bruno
2013
iii
Processing of Seismic Reflection Data Using MATLAB™
Wail A. Mousa and Abdullatif A. Al-Shuhail
2011

Fixed-Point Signal Processing


Wayne T. Padgett and David V. Anderson
2009

Advanced Radar Detection Schemes Under Mismatched Signal Models


Francesco Bandiera, Danilo Orlando, and Giuseppe Ricci
2009

DSP for MATLAB™ and LabVIEW™ IV: LMS Adaptive Filtering


Forester W. Isen
2009

DSP for MATLAB™ and LabVIEW™ III: Digital Filter Design


Forester W. Isen
2008

DSP for MATLAB™ and LabVIEW™ II: Discrete Frequency Transforms


Forester W. Isen
2008

DSP for MATLAB™ and LabVIEW™ I: Fundamentals of Discrete Signal Processing


Forester W. Isen
2008

The Theory of Linear Prediction


P. P. Vaidyanathan
2007

Nonlinear Source Separation


Luis B. Almeida
2006

Spectral Analysis of Signals: The Missing Data Case


Yanwei Wang, Jian Li, and Petre Stoica
2006
Copyright © 2019 by Morgan & Claypool

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

ISBN: 9781681734491 paperback


ISBN: 9781681734507 ebook
ISBN: 9781681734514 hardcover

DOI 10.2200/S00879ED2V01Y201810SPR015

A Publication in the Morgan & Claypool Publishers series


SYNTHESIS LECTURES ON SIGNAL PROCESSING

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

Nasser Kehtarnavaz, Fatemeh Saki, and Adrian Duran


University of Texas at Dallas

SYNTHESIS LECTURES ON SIGNAL PROCESSING #15

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

2 Software Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21


2.1 Android Tools Installation Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.1.1 Java JDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.1.2 Android Studio Bundle and Native Development Kit . . . . . . . . . . . . . . 22
2.1.3 Android Studio Setup Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.1.4 Android Emulator Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.1.5 Getting Familiar with Android Software Tools . . . . . . . . . . . . . . . . . . . 31
2.2 iOS Tools Installation Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.2.1 Iphone App Development with Xcode . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.2.2 Setting-Up App Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.2.3 Creating Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
viii
2.2.4 Implementing C Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.2.5 Executing C Codes Via Objective-C . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.2.6 iOS App Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

3 From MATLAB Coder to Smartphone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49


3.1 MATLAB Function Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.2 Generating Signals via MATLAB on Smartphones . . . . . . . . . . . . . . . . . . . . . 51
3.2.1 Test Bench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.2.2 C Code Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.2.3 Source Code Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.3 Running MATLAB Coder-Generated C Codes on Smartphones . . . . . . . . . 57
3.3.1 Running on Android Smartphones . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.3.2 Running on iOS Smartphones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.4 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

4 Linear Time-Invariant Systems and Convolution . . . . . . . . . . . . . . . . . . . . . . . 65


4.1 Convolution and Its Numerical Approximation . . . . . . . . . . . . . . . . . . . . . . . . 65
4.2 Convolution Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
4.3 Convolution Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.4 Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.4.1 Echo Cancellation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.4.2 Noise Reduction Using Mean Filtering . . . . . . . . . . . . . . . . . . . . . . . . . 95
4.4.3 Impulse Noise Reduction Using Median Filtering . . . . . . . . . . . . . . . . 96
4.5 Running MATLAB Coder-Generated C Codes on Smartphones . . . . . . . . . 96
4.5.1 Running on Android Smartphones . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.5.2 Running on iOS Smartphones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
4.6 Real-Time Running on Smartphones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
4.6.1 MATLAB Function Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
4.6.2 Test Bench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
4.6.3 Modifying Real-Time Shell for Android . . . . . . . . . . . . . . . . . . . . . . . 103
4.6.4 Modifying Real-Time Shell for iOS . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.7 Real-Time Labs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
4.7.1 Android Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
4.7.2 iOS Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
4.7.3 Android Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
4.7.4 iOS Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
4.8 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
ix
5 Fourier Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
5.1 Fourier Series Numerical Computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
5.2 Fourier Series and Its Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
5.3 Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
5.3.1 RL Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
5.3.2 Doppler Effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
5.3.3 Synthesis of Electronic Music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
5.4 Real-Time Labs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
5.4.1 Android Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
5.4.2 iOS Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
5.4.3 Android Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
5.4.4 iOS Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
5.5 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

6 Continuous-Time Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169


6.1 CTFT and Its Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
6.2 Numerical Approximations of CTFT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
6.3 Evaluating Properties of CTFT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
6.4 Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
6.4.1 Circuit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
6.4.2 The Doppler Effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
6.4.3 Diffraction of Light . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
6.5 Real-Time Labs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
6.5.1 Android Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
6.5.2 iOS Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
6.5.3 Android Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
6.5.4 iOS Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
6.6 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

7 Digital Signals and Their Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227


7.1 Digital Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
7.1.1 Sampling and Aliasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
7.1.2 Quantization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
7.1.3 A/D and D/A Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
7.1.4 DTFT and DFT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
7.2 Analog-to-Digital Conversion, DTFT, and DFT . . . . . . . . . . . . . . . . . . . . . 237
x
7.3 Lab Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
7.3.1 Dithering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
7.3.2 Image Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
7.3.3 DTMF Decoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
7.4 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

Authors’ Biographies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

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.

Nasser Kehtarnavaz, Fatemeh Saki, and Adrian Duran


Fall 2018
1

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.

1.1 STARTING MATLAB


Assuming MATLAB is installed on the laptop or computer used, select MATLAB from the
Start bar of Windows, as illustrated in Figure 1.1. After starting MATLAB, a window called
MATLAB desktop appears, see Figure 1.2, which contains other subwindows or panels. The
panel Command Window allows interactive computation to be conducted. Suppose it is desired
to compute 3 C 4  6. This is done by typing it at the prompt command denoted by >> ; see
Figure 1.3. Since no output variable is specified for the result of 3 C 4  6, MATLAB returns the
value in the variable ans , which is created by MATLAB. Note that ans is always overwritten
by MATLAB, so, if the result is used for another operation, it needs to be assigned to a variable,
for example x D 3 C 4  6.
In practice, a sequence of operations is usually performed to achieve a desired output.
Often, a so-called m-file script is used for this purpose. An m-file script is a simple text file where
MATLAB commands are listed. Figure 1.4 shows how to start a new script. In the HOME
menu, locate the New Script tab under New ! Script, or Ctrl+N to create a blank script under the
panel EDITOR. When a new script is opened, it looks as shown in Figure 1.5. A script can be
saved using a specified name in a desired location. An m-file script is saved with “.m” extension.
When such a file is run, MATLAB reads the commands and executes them as though there
were the MATLAB commands and operations. The following section provides more details on
the MATLAB commands and operations.

1.1.1 ARITHMETIC OPERATIONS


There are four basic arithmetic operators in m-files:

+ addition
- subtraction
2 1. INTRODUCTION TO MATLAB

Figure 1.1: MATLAB appearance in the Windows Start bar.


1.1. STARTING MATLAB 3

Current Directory: You can change it to any desired one

Workspace:
View variables that
are created and
stored during a
MATLAB session

Command Window: Write MATLAB


functions at prompt command line (>>)

Command History:
View or run
previously executed
functions

Current Folder: View the


files in the current directory

Figure 1.2: MATLAB interface window.

Figure 1.3: A simple computation in the Command Window.


4 1. INTRODUCTION TO MATLAB

Figure 1.4: Starting a new m-file script in MATLAB.

Figure 1.5: An m-file script docked in the EDITOR panel.


1.1. STARTING MATLAB 5

* multiplication
/ division (for matrices, it also means inversion)

The following three operators work on an element-by-element basis:

.* multiplication of two vectors, element-wise


./ division of two vectors, element-wise
.^ raising all the elements of a vector to a power
p
As an example, to evaluate the expression a3 C bd 4c , where a D 1:2, b D 2:3, c D
4:5, and d D 4, type the following commands in the Command Window to get the answer
( ans ):

>> 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.

1.1.2 VECTOR OPERATIONS


Consider the vectors x D Œx1 ; x2 ; :::; xn  and y D Œy1 ; y2 ; :::; yn . The following operations in-
dicate the resulting vectors:

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

That is, x .* y means Œ1  4; 3  5; 4  6 D Œ4 15 24.

1.1.3 COMPLEX NUMBERS


MATLAB supports complex numbers. The imaginary number is denoted with the symbol i or
j, assuming that these symbols have not been used any other place in the program. It is critical
to avoid such symbol conflicts for obtaining correct outcome. Enter the following and observe
the outcomes:
>> z=3 + 4i % note the multiplication sign '*' is not needed after 4
>> conj(z) % computes the conjugate of z
>> angle(z) % computes the phase of z
>> real(z) % computes the real part of z
>> imag(z) % computes the imaginary part of z
>> abs(z) % computes the magnitude of z
1.1. STARTING MATLAB 7
One can also define an imaginary number with any other user-specified variables. For
example, in the following manner:
>> img=sqrt(-1)
>> z=3 + 4*img
>> exp(pi*img)

1.1.4 ARRAY INDEXING


In m-files, all arrays (vectors) are indexed starting from 1; in other words, x(1) denotes the first
element of the array x. Note that arrays are indexed using parentheses (.) and not square
brackets [.] , as done in C/C++. To create an array featuring the integers 1–6 as elements,
enter:
>> x=[1,2,3,4,5,6]

Alternatively, the notation ':' can be used as follows:


>> x=1:6

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

Additional examples are listed below:


>> ii=2:4:17
>> jj=20:-2:0
>> ii=2:(1/10):4

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]

To access a subset of this array, type the following:


>> x(3:7)
>> length(x) % gives the size of the array or vector
>> x(2:2:length(x))
8 1. INTRODUCTION TO MATLAB
1.1.5 ALLOCATING MEMORY
Memory can get allocated for 1-dimensional arrays (vectors) using the command or function
zeros . The following command allocates memory for a 100-dimensional array:

>> 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

1.1.6 SPECIAL CHARACTERS AND FUNCTIONS


Some widely used special characters used in m-files are listed in Table 1.1. Some widely used
functions are listed in Table 1.2.
Here is an example of the function length ,

>> 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

Table 1.2: Some widely used functions

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

1.1.7 CONTROL FLOW


m-files have the following control flow constructs:

• 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

See the value of 'str' after running the above code.


while
x=-10;
while x<0
x=x+1;
end

See the value of x after running the above code.


for loop
>>x=0;
for j=1:10
x=x+j;
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.

Table 1.3: Relational operators

Symbol Meaning
<= less than equal
< less than
>= greater than equal
> greater than
== equal
~= not equal

Table 1.4: Logical operators

Symbol Meaning
& AND
| OR
~ NOT

1.1.8 PROGRAMMING IN MATLAB


Open a new script file as displayed in Figures 1.3 and 1.4. Save it first in a desired directory. Then
write your MATLAB code and press Run button from the EDITOR panel. For instance, to
write a program to compute the average (mean) of a vector x, the program should use the vector x
as its input and return the average value. To write this program, follow the steps outlined below.
Type the following in an empty window:
x=1:10
L=length(x);
sum=0;
for j=1:L
sum=sum+x(j);
end
y=sum/L % the average of x
12 1. INTRODUCTION TO MATLAB
From the EDITOR panel, go to save ! Save As and enter average.m for the filename.
Then click on the Run button to run the program. Figure 1.6 shows the MATLAB interactive
window after running the program.

Figure 1.6: m-file script interactive window after running the program average.

1.1.9 SOUND GENERATION


Assuming the computer used has a sound card, one can use the function sound to play back
speech or audio files through its speakers. That is, the function sound(y,FS) sends the signal in
a vector y (with sample frequency FS) out to the speaker. Stereo sounds are played on platforms
that support them, with y being an N-by-2 matrix.
Type the following code and listen to a 400 Hz tone:
1.1. STARTING MATLAB 13

>> t=0:1/8000:1;
>> x=cos(2*pi*400*t);
>> sound(x,8000);

Now generate a noise signal by typing:


>> noise=randn(1,8000); % generate 8000 samples of noise
>> sound(noise,8000);

The function randn generates Gaussian noise with zero mean and unit variance.

1.1.10 LOADING AND SAVING DATA


One can load or store data using the commands load and save . To save the vector x of the
above code in the file data.mat, type:
>> save('data.mat', 'x')

To retrieve the data previously saved, type:


>> load data

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.

1.1.11 READING WAVE AND IMAGE FILES


With MATLAB, one can read data from different file types (such as .wav, .jpeg, and .bmp) and
load them in a vector.
To read an audio data file with .wav extension, use the following command:
>> [y,Fs]=audioread('filename')

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.

1.1.12 SIGNAL DISPLAY


Graphical tools are available in MATLAB to display data in a graphical form. Throughout the
book, signals in both the time and frequency domains are displayed using the function plot,

>> plot(x,y)

This function creates a 2-D line plot of the data in y vs. corresponding x values.

1.2 MATLAB PROGRAMMING EXAMPLES


In this section, several simple MATLAB programs are presented.

1.2.1 SIGNAL GENERATION


In this example, we see how to generate and display continuous-time signals in the time domain.
One can represent such signals as a function of time. For simulation purposes, a representation
of time t is needed. Note that the time scale is continuous while computers handle operations
in a discrete manner. Continuous time simulation is achieved by considering a very small time
interval. For example, if a 1-s duration signal in millisecond (ms) increments (time interval of
0.001 s) is considered, then one sample every 1 ms or a total of 1,000 samples are generated
for the entire signal leading to a continuous signal simulation. This continuous-time signal ap-
proximation or simulation is used in later chapters. It is important to note that a finite number
of samples is involved in the simulation of a continuous-time signal, and thus to differentiate
a continuous-time signal from a discrete-time signal, a much higher number of samples per
second for a continuous-time signal needs to be used (very small time interval).
Figure 1.7 shows two continuous-time signals x1.t/ and x2.t / with a duration of
3 s. By setting the time interval dt to 0.001 s, there is a total of 3,000 samples at t D
0; 0:001; 0:002; 0:003; : : : ; 2:999 s. Note that throughout the book, the notations dt , delta, and 
are used interchangeably to denote the time interval between samples.
The signal x1.t/ can be represented mathematically as follows:
8
< 0 0t <1
x1.t/ D 1 1t <2 : (1.1)
:
0 2t <3
1.2. MATLAB PROGRAMMING EXAMPLES 15
x1(t) x2(t)

2 2

0 1 2 3 t 0 1 2 3 t

Figure 1.7: Continous-time signals.

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:

x1=[ zeros(1,1/dt) 2*ones(1,1/dt) zeros(1,1/dt)]

The signal x2.t / can be represented mathematically as follows:


8
< 2t 0t <1
x2.t / D 2t C 4 1  t < 2 : (1.2)
:
0 2t <3

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

Figure 1.8: MATLAB code of a signal generation example.

Figure 1.9: Signal plots.

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 .

Figure 1.10: Periodic signal generation example.


Another random document with
no related content on Scribd:
Schubert—Maker of Songs

And now we come to Franz Peter Schubert (1797–1828), born in


Vienna of a schoolmaster father, and a mother, who, like
Beethoven’s, was a cook.
The musical comedy, Blossom Time, was built upon some of
Schubert’s most beautiful melodies and episodes from his life. We
must never trust too far stories told this way, which often contain
unreliable details, however this charming operetta gives an
interesting glimpse of Schubert’s devotion to composition. It is true
that he wrote wherever he was, covering his cuffs as well as the
menus and programs in the taverns with the endless flow of themes
which eventually became world-famous songs. Schubert was not a
mere writer of songs; he created the form known as Lieder and
through all his works, torrents of melody seemed to spring from him
eternally.
He was the thirteenth of nineteen children, five of which were of a
second marriage, and there was no wealth or luxury for Franz, so his
father worked hard to pay for his music lessons.
His teacher said that no matter what he tried to teach him in
violin, piano, singing, the organ or thorough-bass, Franz knew it
already, for he learned everything almost at a glance.
He was first soprano in the church choir of Lichtenthal and the
beauty of his voice attracted much attention. He also played the
violin in the services, and stole little stray minutes to write songs or
pieces for strings and piano.
When he was sent to the school for Imperial choristers the boys
laughed at his coarse, grey clothing, the big “Harold Lloyd
spectacles,” and his retiring, bashful manners. They soon changed
when they discovered the astonishing things he could do. His home-
spun clothes were exchanged for the uniform trimmed with gold lace
worn by the Imperial choristers, who formed an orchestra to practise
daily music by Haydn, Mozart, Cherubini and Beethoven. Among
them was Spaun and when he won his confidence, Franz told him
that he had written many pieces and he would write more, but could
not afford to buy the music paper. His new friend made it possible
for Schubert to have paper and many other luxuries, in which Spaun
did something to benefit the world,—a little kindness which brought
great results.
The extreme ease with which Schubert absorbed all learning made
him neglect the study of counterpoint, because after all he could not
give all his time to music, for he was a schoolteacher and had to work
hard to get along. His heart was not in his work, for while hearing the
pupils recite he wrote themes on every scrap of paper he could find.
He wrote with lightning rapidity. The early songs met with
immediate favor which encouraged him to write music in larger
form. He was of the people and wrote from the heart, and to the
heart. He hoped for the same success with his symphonies and
chamber music, but the symphonies never reached the perfection of
his songs, and his disappointment was keen when the critics did not
rate them as highly.
However, the steady flow of melody, the torrent of themes, never
ended and his chamber music is like a song with lovely play of
instruments. Who can forget the haunting beauty of the Unfinished
Symphony? This was left unfinished, indeed, not by Schubert’s death
as many suppose, but the composer felt that he had arrived at a
summit of beauty in the second movement, and he dared not add a
third, lest he could not again reach the heights.
His tenth and last symphony in C major takes an hour to perform
and is heard frequently. Robert Schumann wrote that it was of
“Heavenly length.”
Schubert lived when the romantic poets gave him wonderful verse
for his texts. He loved the literature of Goethe and Heinrich Heine,
both of whom knew the hearts of the simple people.
The world will never forget the wonderful heritage left by this
genius who died at thirty-two leaving vast quantities of great works.
Besides creating new forms in song he also gave the pianists pieces
that were new and important. He left no concertos, nor did he write
for solo violin, but his piano sonatas and chamber music are of value.
Der Erl-Koenig (The Erl King), Der Doppelganger (The Shadow),
and Death and the Maiden, all sounded the last note in tragedy, and
he also wrote many lovely songs in lighter mood.
The Well Favored Mendelssohn

Most masters who have left the world richer for having lived, were
born in poverty and knew the sorrows of privation, not so with Felix
Mendelssohn-Bartholdy (1809–1847), loved by the many who have
played his Songs Without Words, or who have heard Elman’s fingers
fly over his violin in the concerto, said to be the best writing ever
done for that instrument.
Popular as are many works from the polished and fluent pen of
Mendelssohn, the oratorios Elijah and Saint Paul are noble for these
contain some of the most dramatic and inspired writing. In that work
which is typical of Mendelssohn and his personality, he showed more
characteristics of the older classical school than of the romantic. If he
had lived during the classical period he would have been a greater
composer, for he was romantic by influence and classic in taste.
Has not the Spring Song the shimmer of spring and the Spinning
Song the whir of the wheels? One can easily imagine the kindly touch
of a loving hand in Consolation, while the Hunting Song is alive and
going. This is the romantic music that became the model for
thousands of small pieces.
It in said frequently that if Mendelssohn had been less
conventional, his work would have been more forceful, because he
had much that was truly fine.
Mendelssohn lived among the most brilliant literary lights of his
day. His refinement was reflected in his music. He was petted by an
adoring father, mother and sisters, who gave him every opportunity
to study and compose, and he was much sought after socially. He
devoted much time to the study of languages, sketching in water
colors and traveling in Italy and Switzerland. His sister Fanny, whose
musical education was of the utmost assistance to her brother whom
she idolized, would have been famous but for her father’s prejudice
against women in professional life. She was a gifted composer and it
is claimed that she wrote many of her brother’s songs and some of
the Songs Without Words.
Her death was a mortal blow from which Mendelssohn never
recovered. Extremely sensitive, his affection for his family was most
intense and filled his life.
His grandfather was the eminent philosopher Moses Mendelssohn,
who being a Hebrew, was open to the sorrows caused by prejudice.
He was such a great man, however, that he succeeded in breaking
down barriers not only for himself, but for his race.
Abraham Mendelssohn was pleased to call himself, “First the son
of the famous Moses Mendelssohn, then the father of the eminent
Felix Mendelssohn.” His banking house in Berlin is still in the family.
The most noted musicians and artists were entertained in the
Mendelssohn home, and heard the compositions of the gifted young
man. In 1821 the boy was taken to Goethe’s home where he played
and improvised for the poet. He was delighted with him for his
musical talent, and because he had inherited the gift of conversation
and letters from his grandfather, of whom Goethe was very fond.
Young Mendelssohn never shocked the great old poet as did
Beethoven, for his manner was always correct.
In 1825 Mendelssohn went to Paris to Cherubini who was asked
whether his talent justified cultivation beyond the average stage. The
master was very enthusiastic, but his father would not leave him in
Paris, even in charge of the noted teacher. Returning to Berlin he
wrote the overture to Midsummer Night’s Dream (1826). It reflects
the dancing elves and the humor of Shakespeare, while the orchestra
has a delicate touch, similar to that shown by Berlioz at the same
period. Mendelssohn was only seventeen when he wrote it, with all
its finish and its flawless musical treatment. Much that he did at that
period shows his natural flow of genius. Music seemed to gush from
his soul like pure, fresh water from a spring, making one think of
cool fountains, sparkling with melody and clarity. These qualities are
also in the Fingal’s Cave or Hebrides overture, and he takes you on
his delightful trips in Calm Sea and Prosperous Voyage. The way
these numbers reflect his impressions and the way he transmitted
them to others is typical of the Romantic School. The purity of his
musical form related him to the classical and gave inklings of the
Symphonic Tone Poem.
In his symphonies Mendelssohn also told tales of his travels, as in
the Italian Symphony, and in his Scotch Symphony in which he
made use of Scotch folk tunes. He also wrote much chamber music.
He left some piano concertos which may not attract the professionals
of today but are the joy of many piano students who play them
arranged for two pianos.
Mendelssohn tried operas but like many others failed to find a
good libretto. This was the trouble with one he produced in Berlin.
Added to this there were many intrigues and jealousies at the opera
house which turned him bitterly against that city.
However, he accomplished one of the greatest things ever done for
music. The works of Bach and Handel had been so neglected that
they were almost forgotten. He knew them well, and wanting others
to love them as he did, he assembled a great chorus and gave Bach’s
Passion according to Saint Matthew. This was the first performance
since Bach’s death, and it brought these works back to us. Imagine
Mendelssohn’s popularity and talent as a conductor to have been
able to do this at the age of twenty! Then he traveled again, and after
roaming through Italy, Switzerland and France, he went to London
where he created a stir as pianist, composer and conductor. Besides
his splendid education he had a winsome and attractive personality,
and his success was very great. He made, in all, nine visits to
England.
Having been brought up in the Christian faith, he married the
daughter of a French Protestant minister and had five children. They
went to live in Germany and becoming conductor of the Leipsic
Gewandhaus orchestra, he made the city the musical center of
Germany. He founded the Leipsic Conservatory of Music (1843),
where he gave his old teacher Moscheles an important post. This
conservatory is well known here for many American musicians of the
last generation were educated there.
Mendelssohn conducted many festivals and he always aroused new
interest in Bach, whom he presented at every opportunity.
His Saint Paul had success in Duesseldorf (1837), and during his
last visit to England (1846), he gave at the Birmingham festival
Elijah, second today in popularity only to Handel’s Messiah.
When Mendelssohn returned to Leipsic, he showed traces of
overwork and the death of his sister coming at the same time, made
him unable to resist the strain. He died November 4, 1847, when only
38. His happy life shines through his music so full of beauty and
sunshine.
Schumann—The Supreme Poet

Robert Schumann (1810–1856), a tower of beauty, strength,


imagination and dramatic fervor even judged by 20th century
standards, still thrills us as we recognize his genius. What a price he
paid for his life filled with joys and griefs!
We are grateful for the solidity of his building, his breadth of
vision, the wonders of his imagination, the beauty of his poetic fancy,
and above all, the vastness of his musical knowledge. A peak among
the composers of the Romantic School, he has scaled the heights of
dramatic fervor as he has touched the sun-flecked valleys. To him we
owe the naming of pieces, and the feeling of emotion which the
composer felt when he named them,—The Happy Farmer, The
Prophet Bird, The Rocking-Horse, End of the Song, The Child Falls
Asleep, etc.
All who have been milestones in music have been well educated,
yet how unjustly people say musicians know nothing but music.
Many have not had only culture from their studies, but also have
come from refined homes. So Schumann, born at Zwickau, Saxony,
had an educated father, a book-seller. His mother wanted Robert to
be a lawyer, and did not wish his musical talent to interfere. He
began to compose and study music at seven, but he studied law,
literature and philosophy, later, at the University of Leipsic.
After a year he went to the famous University of Heidelberg
(1829), which has always been proud that the great composer was
one of its students.
Schumann returned to Leipsic on account of the musical life. With
his return began the romance of his life, one of the most beautiful
love stories in musical history. He studied with Frederick Wieck,
whose little daughter Clara was a prodigy pianist. He became a
member of the household and was charmed by the talent of the child.
Meanwhile he was studying as pianist, and being ingenious, he
invented an instrument to develop his weak fourth finger, but it
ruined his hand and unfitted him for his career.
Now he gave more attention to composition and to musical
criticism. This gave him the chance to help some of the brilliant
musicians of the day. He brought Chopin to the notice of Germany,
and proclaimed the genius of young Johannes Brahms. He also
formed a deep friendship for Mendelssohn.
Valuable as are all writings which reveal his thoughts, his richest
gift to the world was his music, in which he preached the gospel of
beauty.
As Schumann grew into manhood he began to know the depths of
sorrow, some of his finest works having been an outburst of his
tortured soul. Clara Wieck was now a young woman and a great
pianist. It was natural that an affection should spring up between
them. But Clara’s father had greater hopes. He could not see a
struggling young musician and critic as the husband of his talented
child. During this long and painful courtship when Schumann dared
not speak his love to Clara he wrote compositions with which to tell
his story, and she understood. One of these expressions was the
lovely Warum asking the question, “Why?” so longingly.
In those days a case could be brought into court and the reason
demanded why a parent should refuse to allow a marriage.
Schumann went to law, and the court decided that Wieck’s objections
were without cause. But the year of strain told upon his health and
nerves and he began his married life under a cloud of illness. The
young pair were ideally happy, he wrote glorious music, and she took
pride in playing his piano works on all her programs.
With all her accomplishments—and she was a great artist—she was
first a devoted wife who cared for her husband as though he had
been her child. Schumann’s very finest work was done during these
years. His inspiration drove him chiefly to songs, full of lyric beauty
like Schubert’s; indeed, when speaking of lieder the names of
Schubert and Schumann are always linked.
Mendelssohn urged Schumann to teach in the Leipsic
Conservatory, but he left there soon to make a tour of Russia with his
wife. That year they settled in Dresden, a quieter city, because his
nerves were beginning to forecast the shadow of his future.
Mendelssohn loved Schumann and admired him as composer,
writer and critic. He conducted the first performance of Schumann’s
B flat symphony at a Gewandhaus concert of Clara Schumann, and
the happiness of the three was tremendous. Schumann did not think
of himself alone, but was always trying to help his colleagues.
Schubert wrote his C major symphony in March of the year he died
and never heard it, but Schumann had the score sent to Mendelssohn
in Leipsic for its first performance after a wait of eleven years.
Notwithstanding his nerves, Schumann was now in his full power
and the amount he wrote is incredible. Most of his chamber music
was written in 1842, three of the string quartets being dedicated to
Mendelssohn. The work that gave him fame all over Europe was the
quintet for piano and strings, opus 44; with Clara at the piano,
Berlioz heard its first performance and spread the news of his genius
through Paris. About this time the Variations for Two Pianos were
written and played by Robert and Clara Schumann.
Another interesting and popular number is Carnaval, a collection
of named sketches in three-four time each one portraying some
person or thing. Eusebius and Florestan have caused much curiosity
—the secret is that Schumann was a student of himself and these
were meant to show his conflicting moods. Chopin is represented,
also Mendelssohn, while Chiarina is Clara.
A strange thing happened to Schumann in Vienna. He was visiting
the graves of Beethoven and Schubert which are not far apart, and he
found a steel pen on Beethoven’s tomb. He took this for an omen, but
used it only for his most precious works. He wrote the B flat
symphony with it and the magic seemed to work!
Schubert is universally praised for the beauty of his themes, but
who could surpass the loveliness of Schumann’s melodies? The
contrasts between the exquisite little tone-pictures of Kinderscenen
and the grandeur of the sonatas and the Fantasia mark the breadth
of his genius, while the amount he accomplished in his short span of
life was marvelous.
He was but twenty-five when he first showed mental trouble, and
at forty-four his case was hopeless. He tried to end his life by
jumping into the Rhine and was taken to an asylum near Beethoven’s
birthplace, Bonn, where he died two years later, survived by his wife
and two daughters.
What a price he paid for his life filled with joys and griefs!
Chopin—“Proudest Poet-Soul”

Robert Schumann wrote that Chopin was “the boldest, proudest


poet-soul of his time.” Such a tribute from him meant more than all
the praise we can give him now; it shows that he had admiration and
respect from his rivals as he had idolatry from the literary, artistic
and refined circles of Paris.
Frederic Chopin (1809–1849) was born in Poland of a French
father and a Polish mother. The difference one finds in the date of his
birth, February 22 or March 1, is owing to the difference between the
Russian and Polish calendars, and those of other countries.
Like Mozart he showed talent very early and at nine played his first
public concert. His mother, unable to be present, asked him what the
audience liked best. “My collar, Mamma!” he answered, proud of the
little lace collar on the black velvet jacket! He was elegant then, and
always kept his air of distinction, and a love for beauty.
Shortly after beginning music study, Chopin tried to compose, and
felt such authority that he undertook to change certain things written
by his teacher. His earliest work was a march dedicated to the Grand
Duke Constantin, which was arranged for brass-band and printed
without the composer’s name.
From his two teachers in Poland, both ardent patriots, Chopin
must have absorbed much of the national feeling so strongly marked
in his works. As it was a day of flashy salon (Page 322) playing, his
teacher, Joseph Elsner, felt that Chopin was the founder of a new
school in which poetic feeling was leading music out of the prevailing
empty acrobatic finger feats!
The world owes much to that wise teacher who instilled a love of
Bach into his young pupil. He answered some one who blamed him
for allowing Chopin too much freedom: “Leave him alone! he treads
an extraordinary path because he has extraordinary gifts and follows
no method, but creates one. I have never seen such a gift for
composition.” Later he marked his examination papers: “Chopin,
Frederic (pupil for three years), astounding capacity, musical
genius.”
At fifteen Chopin was adored by his companions and always held
the affection of those who knew him. He seems to have been the
original “matinee idol” of Paris, whenever he played, for he was the
most poetic and finest pianist ever heard.
Though Chopin was seemingly French in manner, habits and
tastes, he was extraordinarily patriotic and his music is perhaps the
finest expression of Poland the world has ever seen.
No one has surpassed, or even equalled Chopin in writing for the
piano. He understood its possibilities, limitations, tonal qualities and
power to express emotion.
He did not leave a great quantity of compositions, but a well-
ordered collection of music, so individual that even today, with all his
imitators, when we hear Chopin—(and where is there a piano recital
without at least one number?)—we instantly recognize it as his.
Strongly marked rhythms are among his most fascinating
characteristics. He glorified and elaborated the dances of Poland, as
had others in the past, who made art pieces of the gavotte, minuet,
bourrée, gigue, etc.
What lovelier numbers on a program than Chopin’s mazurkas,
polonaises, waltzes? There is also irresistible swing in the Ballades,
Impromptus, the Berceuse, Barcarolle, and what could rival in
fantasy the Nocturnes or Preludes? The Etudes cover a variety of
moods, while his Scherzos stand alone in piano literature.
Chopin left no symphonies, no chamber music, except two piano
sonatas and one for ’cello and piano, and what he did for voice could
be told in a few words. He also wrote two piano concertos in which
the piano work is beautiful but the orchestration is not as fine.
These concertos and his piano sonatas were the largest forms in
which he wrote, proving that he could have succeeded here had he
not chosen to perfect music in the smaller forms.
Chopin never had a fair start in life in the way of health, and while
his delicate appearance made him the more interesting, especially to
the ladies, he was a real sufferer. It would be unfair to believe that his
work would have been greater had he enjoyed complete health, for
his unhappiness and his sufferings gave him a sense of the
mysterious and the beyond. He lived in a world far from material
things and seemed able to translate all he felt into music.
He had the devotion of many idolizing friends, tireless in their
efforts to make him happy and keep him working so that he should
not brood over his illness (tuberculosis). Foremost among these was
the famous French novelist George Sand, whose love and
companionship were the source of rare inspiration and comfort. She
was a woman of vast mental and physical power and seemed to
impart her strength to him. But Chopin was a favorite not only with
women but among the men, as we learn through the letters he left.
We find many from Schumann, Mendelssohn, Liszt, Delacroix, the
French painter, and innumerable others.
Concertizing began to fatigue him beyond endurance. Returning to
Paris from a tour during a hard winter in England, he grew so ill that
he rarely left his bed, although he did not die until the following
October, 1849.
Chopin had asked that the Mozart Requiem be given at his funeral,
which occurred October 30, from the Madeleine Church in Paris. The
singer Lablache who had sung the Mozart number at Beethoven’s
funeral also performed this tribute for Chopin.
In addition to the Requiem, Lefebure-Wely, one of the fine
organists of Paris, played Chopin’s preludes in B and E minor, and
the familiar funeral march from the first sonata was arranged for
orchestra and played for the first time.
Heller—The Children’s Chopin

We may not find the name of Stephen Heller (1813–1888) on


many of the “grown-up” programs, but no pupils’ recitals are
complete without several of his lovely melodies.
He was the friend of children and devoted himself more to
teaching and writing for the young minds and small hands than did
any of his companions. Heller was intended for a lawyer, but his
talent as shown at nine was great enough for him to study with Carl
Czerny in Vienna. He became a fine concert pianist and toured
Europe. Taken ill during one of these tours, he was adopted by a
wealthy family who allowed him all the time he wanted for
composing. Most of his study was done in Paris where he was a
friend of Berlioz, Chopin, Liszt and other prominent artists of the
day.
He left several hundred piano pieces, nearly all masterpieces in a
field where he stands practically alone. He wrote in the style
developed by Mendelssohn and Schumann, and what Chopin is to
the music world of the “grown-ups,” Heller is to the young student.
Painted by
Kriehuber.

Franz Schubert.
After the Painting
by Bendemann.

Robert Schumann.
Felix Mendelssohn-Bartholdy.
After the Painting
by F. V. Delacroix.

Frédéric Chopin.

Poet Music Writers.

(Romantic School.)
After a painting by
Lenbach.

Richard Wagner, the Wizard.


CHAPTER XXV
Wagner—the Wizard

Wilhelm Richard Wagner


1813–1883

Richard Wagner, the Wizard, called out of the past a vast company
of gods and goddesses, giants, knights and heroes, kings and queens.
He made them live for us with all their joys and sorrows, loves and
hates, in his great music dramas, for which he has been recognized as
one of the rare geniuses of the world.
Evoked by his music-magic they pass before us,—the gods and
heroes of Walhalla,—Wotan, Brünnhilde, valiant Siegfried, Pfafner
the giant who is turned into a dragon, Mime the dwarf, the Rhine
Maidens and the Valkyries; Parsifal the guileless youth who became
the Knight of the Holy Grail, and Lohengrin his son, the beautiful
knight who marries Elsa, a lady of rank of the Middle Ages.
We see the minnesingers Tannhäuser and Wolfram von
Eschenbach in one of their famous Minstrel Tournaments with the
hand of the lovely Elizabeth as a prize; we also meet the lovable
shoemaker-mastersinger Hans Sachs in Nüremberg, of the 16th
century, and David his merry apprentice, lovely Eva Pogner and the
charming knight Walter von Stolzing, and Beckmesser the clownish
mastersinger; then there are the imperious Irish Queen, Isolde and
Tristan, her lover, with Kurvenal his faithful servant. Wagner makes
not only the mythological persons relive but he brings back realistic
pictures of the everyday life and customs of the German people of the
Middle Ages.
Wagner had his idea of what opera should be and nothing short of
his ideal interested him. He kept to his purpose and accomplished
miraculous things whether he suffered or starved or was banished
from his country.
Richard was born at a time, favorable for hearing and knowing the
Viennese composers of the 18th and early 19th centuries, who had
increased the importance of the orchestra. He could hear too the
music of Schumann and Schubert, with all the new beauty and warm
feeling they radiated. This new depth appeared not only in the
orchestra but also in piano and vocal music. In Wagner’s time,
people felt deeply about everything,—science, philosophy, literature,
and especially politics; and many were the quarrels and discontents
among nations. Even our own country was torn by a cruel war.
Wagner listened to the works of Mozart and of Beethoven, whom
he admired immensely. He approved of Beethoven’s use of the
chorus in the Ninth Symphony, which had no little effect on his work
and ideals.
Among the people who most influenced Wagner was Gluck, who
first fought for sincerity and truth in opera drama. Gluck did not
have the advantage of the grown up orchestra and freer forms, yet
Gluck did so much to free opera that Wagner was fortunate indeed to
have come after him. Another great influence was Weber, who mixed
everyday story in a delightful play of fancy and picturesqueness.
Wagner, after hearing Weber’s Die Freischütz, was very much
impressed.
Meyerbeer, a contemporary, although rather artificial and always
working for effects, nevertheless showed Wagner the value of
gorgeous scenic productions. Wagner was fond of the stage, and
Meyerbeer’s big scenes sank into the mind of the young composer-
poet, who liked to be called a poet rather than a musician!
Musically, Franz Liszt was probably the greatest influence in
Wagner’s life and we often hear in Wagner’s works bits of melody
which remind us of Liszt.
It is not fair to say that he was great just because he followed
Gluck, Weber, and Mozart, for he brought music out of its old ruts
and was copied by hundreds of composers.
The hero of this chapter was born in Leipsic in 1813 and was the
youngest of nine children. His father died shortly after his birth and
his mother married an actor playwright named Geyer and they all
went to live in Dresden. His stepfather felt that Richard had musical
gifts and he proved a very kind and wise parent. He died when the
boy was only eight.
Richard must have been a most interesting little chap, for he
always did everything with what we would call “pep” and persistence.
He loved poetry and was devoted to the theatre. His stepfather had
always allowed him to go “back stage” at the playhouse, so the youth
became familiar with stage craft, which he used later in producing
his music dramas.
He read the Greek and German poets and dramatists at a very
early age. He was the first of the musical geniuses to be trained in the
arts before he started music. So we can picture a little chap, “stage-
struck,” studying when he should, seeing plays when he could, and
listening to the works of Weber and Beethoven which enchanted
him, and storing up ideas, but as yet showing no great leaning
toward music as a profession.
The family moved back to Leipsic in 1827 where he went to school
until he entered the university in 1831. He heard much orchestral
music and became so deeply charmed with Beethoven, that he copied
the Ninth Symphony from a score, to become familiar with it. The
Ninth Symphony with chorale takes about two hours to perform,
imagine how long it took to copy it! An instance of the wizard’s
energy and “stick-to-it-iveness”!

You might also like