售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Getting Started with Simulink
Table of Contents
Getting Started with Simulink
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Instant Updates on New Packt Books
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Simulink Facts
What is Simulink?
Programming
Graphical
Problems solved by Simulink
Software specification
Software development
Software testing
Simulink drawbacks
Where Simulink excels
Summary
2. Creating a Model
The MATLAB environment
Command Window – how MATLAB talks to us
The workspace – our treasury chest
The working folder – where MATLAB saves our work
The path – where MATLAB finds the tools
The Simulink interface
Our first model – a cruise controller
Step 1 – create and save the model
Step 2 – do comment the code!
Step 3 – open Simulink Library Browser
Step 4 – add blocks to the model from Library Browser
Step 5 – rename the blocks
Step 6 – implement the algorithm
Step 7 – nest the logic into subsystems
Step 8 – declare workspace variables
Step 9 – do a first simulation
Our second model – the Alfa Romeo 147 GTA
Getting the speed – Newton's laws
The aerodynamic drag equation
The rolling resistance approximation
The engine force – engine, wheels, and transmission
Gearbox and differential
Wheel to RPM
Engine
Torque to force
The finishing touches
Summary
3. Simulating a Model
The mandatory theory
The simulation times – when the math is done
The solvers – these great unknown
Variable-step versus fixed-step solvers
Continuous versus discrete
Stiff versus nonstiff
Build the complete closed-loop system
Configuring the simulation
Simulation times
Solvers
Run our first serious simulation
Calibrate the PI controller
Calibrating Kp
Calibrating Ki
Test with other sources
Sine Wave
Ramp
Signal Builder
Summary
4. Using the Model
The external software – a Qt5 application
The Swiss army knife – S-functions
The simulation phases
Level 2 MATLAB S-function callbacks
The mandatory callbacks
The most useful optional callbacks
The work vector – DWork
MATLAB S-functions – file source and sink blocks
The filesink_msfun block
The MATLAB code
The filesource_msfun block
The MATLAB code
A quick test
Simulink and the real world
Forcing Simulink to sync
Preparing the cruise controller model
Running the simulation on the target application
Going further – C MEX S-functions
Setting up the mex tool
UNIX-like systems (GNU/Linux in particular)
Microsoft Windows systems
How C MEX S-functions work
The required callbacks
mdlInitializeSizes
mdlInitializeSampleTimes
mdlOutputs
mdlTerminate
The most useful optional callbacks
mdlStart
mdlInitializeConditions
mdlUpdate
The DWork vector
The elementary work vectors
The filesource S-function
The beginning – headers and includes
Block properties and memory usage – mdlInitializeSizes
Timings – mdlInitializeSampleTimes
Initial tasks – mdlStart
Core logic – mdlOutputs
Update memories – mdlUpdate
Cleanup – mdlTerminate
The happy ending
Compiling the S-function
Exercise – the filesink S-function
A quick test
Go for another ride
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜