Michael Paluszek and Stephanie Thomas
MATLAB Machine Learning RecipesA Problem-Solution Approach2nd ed.
Michael Paluszek
Plainsboro, NJ, USA
Stephanie Thomas
Plainsboro, NJ, USA
ISBN 978-1-4842-3915-5e-ISBN 978-1-4842-3916-2
Library of Congress Control Number: 2018967208
© Michael Paluszek and Stephanie Thomas 2019
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Introduction

Machine learning is becoming important in every engineering discipline. For example:

  1. 1.

    Autonomous cars. Machine learning is used in almost every aspect of car control systems.

     
  2. 2.

    Plasma physicists use machine learning to help guide experiments on fusion reactors. TAE Systems has used it with great success in guiding fusion experiments. The Princeton Plasma Physics Laboratory has used it for the National Spherical Torus Experiment to study a promising candidate for a nuclear fusion power plant.

     
  3. 3.

    It is used in finance for predicting the stock market.

     
  4. 4.

    Medical professionals use it for diagnoses.

     
  5. 5.

    Law enforcement, and others, use it for facial recognition. Several crimes have been solved using facial recognition!

     
  6. 6.

    An expert system was used on NASA’s Deep Space 1 spacecraft.

     
  7. 7.

    Adaptive control systems steer oil tankers.

     

There are many, many other examples.

Although many excellent packages are available from commercial sources and open-source repositories, it is valuable to understand how these algorithms work. Writing your own algorithms is valuable both because it gives you an insight into the commercial and open-source packages and because it gives you the background to write your own custom machine learning software specialized for your application.

MATLAB ® had its origins for that very reason. Scientists who needed to do operations on matrices used numerical software written in FORTRAN. At the time, using computer languages required the user to go through the write-compile-link-execute process, which was time-consuming and error-prone. MATLAB presented the user with a scripting language that allowed the user to solve many problems with a few lines of a script that executed instantaneously. MATLAB has built-in visualization tools that helped the user to better understand the results. Writing MATLAB was a lot more productive and fun than writing FORTRAN.

The goal of MATLAB Machine Learning Recipes: A Problem–Solution Approach is to help all users to harness the power of MATLAB to solve a wide range of learning problems. The book has something for everyone interested in machine learning. It also has material that will allow people with an interest in other technology areas to see how machine learning, and MATLAB, can help them to solve problems in their areas of expertise.

Using the Included Software

This textbook includes a MATLAB toolbox, which implements the examples. The toolbox consists of:
  1. 1.

    MATLAB functions

     
  2. 2.

    MATLAB scripts

     
  3. 3.

    html help

     
The MATLAB scripts implement all of the examples in this book. The functions encapsulate the algorithms. Many functions have built-in demos. Just type the function name in the command window and it will execute the demo. The demo is usually encapsulated in a sub-function. You can copy out this code for your own demos and paste it into a script. For example, type the function name PlotSet into the command window and the plot in Figure 1 will appear.
 >> PlotSet  
../images/420697_2_En_BookFrontmatter_Fig1_HTML.png
Figure 1

Example plot from the function PlotSet.m.

If you open the function you will see the demo:

  %%% PlotSet>Demo
function  Demo
 x =  linspace (1,1000);
 y = [ sin (0.01*x); cos (0.01*x); cos (0.03*x)];
disp ( ’PlotSet:␣One␣x␣and␣two␣y␣rows’)
 PlotSet( x, y,  ’figure␣title’,  ’PlotSet␣Demo’,...
      ’plot␣set’,{[2 3], 1}, ’legend’,{{ ’A’  ’B’},{}}, ’plot␣title’,
     { ’cos’, ’sin’});  
You can use these demos to start your own scripts. Some functions, such as right-hand side functions for numerical integration, don’t have demos. If you type:
 >> RHSAutomobileXY
 Error using RHSAutomobileXY (line 17)
 a built-in demo is not available.  
The toolbox is organized according to the chapters in this book. The folder names are Chapter_01, Chapter_02, etc. In addition, there is a general folder with functions that support the rest of the toolbox. You will also need the open-source package GLPK (GNU Linear Programming Kit) to run some of the code. Nicolo Giorgetti has written a MATLAB MEX interface to GLPK that is available on SourceForge and included with this toolbox. The interface consists of:
  1. 1.

    glpk.m

     
  2. 2.

    glpkcc.mexmaci64, or glpkcc.mexw64, etc.

     
  3. 3.

    GLPKTest.m

     

which are available from https://​sourceforge.​net/​projects/​glpkmex/​ . The second item is the MEX file of glpkcc.cpp compiled for your machine, such as Mac or Windows. Go to https://​www.​gnu.​org/​software/​glpk/​ to get the GLPK library and install it on your system. If needed, download the GLPKMEX source code as well and compile it for your machine, or else try another of the available compiled builds.

Contents

Index 341

About the Authors

Michael Paluszek
../images/420697_2_En_BookFrontmatter_Figb_HTML.jpg

is President of Princeton Satellite Systems, Inc. (PSS) in Plainsboro, New Jersey. Mr. Paluszek founded PSS in 1992 to provide aerospace consulting services. He used MATLAB to develop the control system and simulations for the Indostar-1 geosynchronous communications satellite. This led to the launch of Princeton Satellite Systems first commercial MATLAB toolbox, the Spacecraft Control Toolbox, in 1995. Since then he has developed toolboxes and software packages for aircraft, submarines, robotics, and nuclear fusion propulsion, resulting in Princeton Satellite Systems current extensive product line. He is working with the Princeton Plasma Physics Laboratory on a compact nuclear fusion reactor for energy generation and space propulsion.

Prior to founding PSS, Mr. Paluszek was an engineer at GE Astro Space in East Windsor, NJ. At GE he designed the Global Geospace Science Polar despun platform control system and led the design of the GPS IIR attitude control system, the Inmarsat-3 attitude control systems and the Mars Observer delta-V control system, leveraging MATLAB for control design. Mr. Paluszek also worked on the attitude determination system for the DMSP meteorological satellites. Mr. Paluszek flew communication satellites on over twelve satellite launches, including the GSTAR III recovery, the first transfer of a satellite to an operational orbit using electric thrusters. At Draper Laboratory Mr. Paluszek worked on the Space Shuttle, Space Station and submarine navigation. His Space Station work included designing of Control Moment Gyro based control systems for attitude control.

Mr. Paluszek received his bachelors degree in Electrical Engineering, and master’s and engineers degrees in Aeronautics and Astronautics from the Massachusetts Institute of Technology. He is author of numerous papers and has over a dozen U.S. Patents. Mr. Paluszek is the author of “MATLAB Recipes” and “MATLAB Machine Learning” both published by Apress.

 
Stephanie Thomas
../images/420697_2_En_BookFrontmatter_Figc_HTML.jpg

is Vice President of Princeton Satellite Systems, Inc. in Plainsboro, New Jersey. She received her bachelors and masters degrees in Aeronautics and Astronautics from the Massachusetts Institute of Technology in 1999 and 2001. Ms. Thomas was introduced to the PSS Spacecraft Control Toolbox for MATLAB during a summer internship in 1996 and has been using MATLAB for aerospace analysis ever since. In her nearly 20 years of MATLAB experience, she has developed many software tools including the Solar Sail Module for the Spacecraft Control Toolbox; a proximity satellite operations toolbox for the Air Force; collision monitoring Simulink blocks for the Prisma satellite mission; and launch vehicle analysis tools in MATLAB and Java,. She has developed novel methods for space situation assessment such as a numeric approach to assessing the general rendezvous problem between any two satellites implemented in both MATLAB and C++. Ms. Thomas has contributed to PSS Attitude and Orbit Control textbook, featuring examples using the Spacecraft Control Toolbox, and written many software Users Guides. She has conducted SCT training for engineers from diverse locales such as Australia, Canada, Brazil, and Thailand and has performed MATLAB consulting for NASA, the Air Force, and the European Space Agency. Ms. Thomas is the author of “MATLAB Recipes” and “MATLAB Machine Learning” both published by Apress. In 2016, Ms. Thomas was named a NASA NIAC Fellow for the project “Fusion-Enabled Pluto Orbiter and Lander”.