ebook img

Introduction to Modeling and Simulation with MATLAB® and Python PDF

211 Pages·2017·7.36 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Introduction to Modeling and Simulation with MATLAB® and Python

Introduction to Modeling and Simulation with MATLAB® and Python Chapman & Hall/CRC Computational Science Series SERIES EDITOR Horst Simon Deputy Director Lawrence Berkeley National Laboratory Berkeley, California, U.S.A. PUBLISHED TITLES COMBINATORIAL SCIENTIFIC COMPUTING Edited by Uwe Naumann and Olaf Schenk CONTEMPORARY HIGH PERFORMANCE COMPUTING: FROM PETASCALE TOWARD EXASCALE Edited by Jeffrey S. Vetter CONTEMPORARY HIGH PERFORMANCE COMPUTING: FROM PETASCALE TOWARD EXASCALE, VOLUME TWO Edited by Jeffrey S. Vetter DATA-INTENSIVE SCIENCE Edited by Terence Critchlow and Kerstin Kleese van Dam ELEMENTS OF PARALLEL COMPUTING Eric Aubanel THE END OF ERROR: UNUM COMPUTING John L. Gustafson EXASCALE SCIENTIFIC APPLICATIONS: SCALABILITY AND PERFORMANCE PORTABILITY Edited by Tjerk P. Straatsma, Timothy J. Williams, and Katerina Antypas FROM ACTION SYSTEMS TO DISTRIBUTED SYSTEMS: THE REFINEMENT APPROACH Edited by Luigia Petre and Emil Sekerinski FUNDAMENTALS OF MULTICORE SOFTWARE DEVELOPMENT Edited by Victor Pankratius, Ali-Reza Adl-Tabatabai, and Walter Tichy FUNDAMENTALS OF PARALLEL MULTICORE ARCHITECTURE Yan Solihin THE GREEN COMPUTING BOOK: TACKLING ENERGY EFFICIENCY AT LARGE SCALE Edited by Wu-chun Feng GRID COMPUTING: TECHNIQUES AND APPLICATIONS Barry Wilkinson HIGH PERFORMANCE COMPUTING: PROGRAMMING AND APPLICATIONS John Levesque with Gene Wagenbreth Chapman & Hall/CRC PUBLISHED TITLES CONTINUED Computational Science Series HIGH PERFORMANCE PARALLEL I/O SERIES EDITOR Prabhat and Quincey Koziol HIGH PERFORMANCE VISUALIZATION: Horst Simon ENABLING EXTREME-SCALE SCIENTIFIC INSIGHT Edited by E. Wes Bethel, Hank Childs, and Charles Hansen Deputy Director Lawrence Berkeley National Laboratory INDUSTRIAL APPLICATIONS OF HIGH-PERFORMANCE COMPUTING: Berkeley, California, U.S.A. BEST GLOBAL PRACTICES Edited by Anwar Osseyran and Merle Giles PUBLISHED TITLES INTRODUCTION TO COMPUTATIONAL MODELING USING C AND OPEN-SOURCE TOOLS COMBINATORIAL SCIENTIFIC COMPUTING José M Garrido Edited by Uwe Naumann and Olaf Schenk INTRODUCTION TO CONCURRENCY IN PROGRAMMING LANGUAGES CONTEMPORARY HIGH PERFORMANCE COMPUTING: FROM PETASCALE Matthew J. Sottile, Timothy G. Mattson, and Craig E Rasmussen TOWARD EXASCALE Edited by Jeffrey S. Vetter INTRODUCTION TO ELEMENTARY COMPUTATIONAL MODELING: ESSENTIAL CONCEPTS, PRINCIPLES, AND PROBLEM SOLVING CONTEMPORARY HIGH PERFORMANCE COMPUTING: FROM PETASCALE José M. Garrido TOWARD EXASCALE, VOLUME TWO Edited by Jeffrey S. Vetter INTRODUCTION TO HIGH PERFORMANCE COMPUTING FOR SCIENTISTS AND ENGINEERS DATA-INTENSIVE SCIENCE Georg Hager and Gerhard Wellein Edited by Terence Critchlow and Kerstin Kleese van Dam INTRODUCTION TO MODELING AND SIMULATION WITH MATLAB® AND PYTHON ELEMENTS OF PARALLEL COMPUTING Steven I. Gordon and Brian Guilfoos Eric Aubanel INTRODUCTION TO REVERSIBLE COMPUTING THE END OF ERROR: UNUM COMPUTING Kalyan S. Perumalla John L. Gustafson INTRODUCTION TO SCHEDULING EXASCALE SCIENTIFIC APPLICATIONS: SCALABILITY AND Yves Robert and Frédéric Vivien PERFORMANCE PORTABILITY Edited by Tjerk P. Straatsma, Timothy J. Williams, and Katerina Antypas INTRODUCTION TO THE SIMULATION OF DYNAMICS USING SIMULINK® Michael A. Gray FROM ACTION SYSTEMS TO DISTRIBUTED SYSTEMS: THE REFINEMENT APPROACH Edited by Luigia Petre and Emil Sekerinski PEER-TO-PEER COMPUTING: APPLICATIONS, ARCHITECTURE, PROTOCOLS, AND CHALLENGES FUNDAMENTALS OF MULTICORE SOFTWARE DEVELOPMENT Yu-Kwong Ricky Kwok Edited by Victor Pankratius, Ali-Reza Adl-Tabatabai, and Walter Tichy PERFORMANCE TUNING OF SCIENTIFIC APPLICATIONS FUNDAMENTALS OF PARALLEL MULTICORE ARCHITECTURE Edited by David Bailey, Robert Lucas, and Samuel Williams Yan Solihin PETASCALE COMPUTING: ALGORITHMS AND APPLICATIONS THE GREEN COMPUTING BOOK: TACKLING ENERGY EFFICIENCY AT LARGE SCALE Edited by David A. Bader Edited by Wu-chun Feng PROCESS ALGEBRA FOR PARALLEL AND DISTRIBUTED PROCESSING GRID COMPUTING: TECHNIQUES AND APPLICATIONS Edited by Michael Alexander and William Gardner Barry Wilkinson PROGRAMMING FOR HYBRID MULTI/MANY-CORE MPP SYSTEMS HIGH PERFORMANCE COMPUTING: PROGRAMMING AND APPLICATIONS John Levesque and Aaron Vose John Levesque with Gene Wagenbreth PUBLISHED TITLES CONTINUED SCIENTIFIC DATA MANAGEMENT: CHALLENGES, TECHNOLOGY, AND DEPLOYMENT Edited by Arie Shoshani and Doron Rotem SOFTWARE ENGINEERING FOR SCIENCE Edited by Jeffrey C. Carver, Neil P. Chue Hong, and George K. Thiruvathukal PUBLISHED TITLES CONTINUED SCIENTIFIC DATA MANAGEMENT: CHALLENGES, TECHNOLOGY, AND DEPLOYMENT Edited by Arie Shoshani and Doron Rotem Introduction to Modeling SOFTWARE ENGINEERING FOR SCIENCE Edited by Jeffrey C. Carver, Neil P. Chue Hong, and George K. Thiruvathukal and Simulation with MATLAB® and Python Steven I. Gordon Brian Guilfoos A CHAPMAN & HALL BOOK MATLAB® and Simulink® are trademarks of the MathWorks, Inc. and are used with permission. The MathWorks does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion of MATLAB® and Simulink® software or related products does not constitute e ndorsement or sponsorship by the MathWorks of a particular pedagogical approach or particular use of the MATLAB® and Simulink® software. CRC Press Taylor & Francis Group 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742 © 2017 by Taylor & Francis Group, LLC CRC Press is an imprint of Taylor & Francis Group, an Informa business No claim to original U.S. Government works Printed on acid-free paper International Standard Book Number-13: 978-1-4987-7387-4 (Hardback) This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this p ublication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, please access www. copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged. Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without intent to infringe. Visit the Taylor & Francis Web site at http://www.taylorandfrancis.com and the CRC Press Web site at http://www.crcpress.com MATLAB® and Simulink® are trademarks of the MathWorks, Inc. and are used with permission. The MathWorks does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion of MATLAB® and Simulink® software or related products does not constitute e ndorsement or sponsorship by the MathWorks of a particular pedagogical approach or particular use of the Contents MATLAB® and Simulink® software. Preface, xiii Authors, xvii Chapter 1 ◾ Introduction to Computational Modeling 1 1.1 THE IMPORTANCE OF COMPUTATIONAL SCIENCE 1 CRC Press Taylor & Francis Group 1.2 HOW MODELING HAS CONTRIBUTED 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742 TO ADVANCES IN SCIENCE AND ENGINEERING 3 © 2017 by Taylor & Francis Group, LLC 1.2.1 Some Contemporary Examples 8 CRC Press is an imprint of Taylor & Francis Group, an Informa business 1.3 THE MODELING PROCESS 9 No claim to original U.S. Government works 1.3.1 Steps in the Modeling Process 11 Printed on acid-free paper 1.3.2 Mathematical Modeling Terminology and International Standard Book Number-13: 978-1-4987-7387-4 (Hardback) Approaches to Simulation 14 This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot 1.3.3 Modeling and Simulation Terminology 14 assume responsibility for the validity of all materials or the consequences of their use. The authors and 1.3.4 Example Applications of Modeling and Simulation 15 publishers have attempted to trace the copyright holders of all material reproduced in this p ublication and apologize to copyright holders if permission to publish in this form has not been obtained. If any EXERCISES 17 copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. REFERENCES 18 Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information Chapter 2 ◾ Introduction to Programming Environments 21 storage or retrieval system, without written permission from the publishers. 2.1 THE MATLAB® PROGRAMMING ENVIRONMENT 21 For permission to photocopy or use material electronically from this work, please access www. 2.1.1 The MATLAB® Interface 21 copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that 2.1.2 Basic Syntax 23 provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged. 2.1.2.1 Variables and Operators 23 Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are 2.1.2.2 Keywords 25 used only for identification and explanation without intent to infringe. 2.1.2.3 Lists and Arrays 26 Visit the Taylor & Francis Web site at http://www.taylorandfrancis.com 2.1.3 Common Functions 28 and the CRC Press Web site at http://www.crcpress.com vii viii ◾ Contents 2.1.4 Program Execution 28 2.1.5 Creating Repeatable Code 29 2.1.6 Debugging 30 2.2 THE PYTHON ENVIRONMENT 30 2.2.1 Recommendations and Installation 30 2.2.2 The Spyder Interface 31 2.2.3 Basic Syntax 32 2.2.3.1 Variables and Operators 32 2.2.3.2 Keywords 34 2.2.3.3 Lists and Arrays 35 2.2.4 Loading Libraries 38 2.2.5 Common Functions 39 2.2.6 Program Execution 40 2.2.7 Creating Repeatable Code 40 2.2.8 Debugging 41 EXERCISES 42 Chapter 3 ◾ Deterministic Linear Models 45 3.1 SELECTING A MATHEMATICAL REPRESENTATION FOR A MODEL 45 3.2 LINEAR MODELS AND LINEAR EQUATIONS 46 3.3 LINEAR INTERPOLATION 49 3.4 SYSTEMS OF LINEAR EQUATIONS 51 3.5 LIMITATIONS OF LINEAR MODELS 51 EXERCISES 52 REFERENCES 53 Chapter 4 ◾ Array Mathematics in MATLAB® and Python 55 4.1 INTRODUCTION TO ARRAYS AND MATRICES 55 4.2 BRIEF OVERVIEW OF MATRIX MATHEMATICS 56 4.3 MATRIX OPERATIONS IN MATLAB® 58 4.4 MATRIX OPERATIONS IN PYTHON 59 EXERCISES 60 Contents   ◾   ix Chapter 5 ◾ Plotting 61 5.1 PLOTTING IN MATLAB® 61 5.2 PLOTTING IN PYTHON 68 EXERCISES 76 Chapter 6 ◾ Problem Solving 79 6.1 OVERVIEW 79 6.2 BOTTLE FILLING EXAMPLE 80 6.3 TOOLS FOR PROGRAM DEVELOPMENT 81 6.3.1 Pseudocode 82 6.3.2 Top–Down Design 82 6.3.3 Flowcharts 83 6.4 BOTTLE FILLING EXAMPLE CONTINUED 84 EXERCISES 85 Chapter 7 ◾ Conditional Statements 87 7.1 RELATIONAL OPERATORS 87 7.2 LOGICAL OPERATORS 88 7.3 CONDITIONAL STATEMENTS 89 7.3.1 MATLAB® 89 7.3.2 Python 92 EXERCISES 95 Chapter 8 ◾ Iteration and Loops 97 8.1 FOR LOOPS 97 8.1.1 MATLAB® Loops 97 8.1.2 Python Loops 98 8.2 WHILE LOOPS 99 8.2.1 MATLAB® While Loops 99 8.2.2 Python While Loops 99 8.3 CONTROL STATEMENTS 100 8.3.1 Continue 100 8.3.2 Break 100 EXERCISES 100

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.