Table Of ContentMatlab - Modelling,
Programming and
Simulations
edited by
Emilson Pereira Leite
SCIYO
Matlab - Modelling, Programming and Simulations
Edited by Emilson Pereira Leite
Published by Sciyo
Janeza Trdine 9, 51000 Rijeka, Croatia
Copyright © 2010 Sciyo
All chapters are Open Access articles distributed under the Creative Commons Non Commercial Share
Alike Attribution 3.0 license, which permits to copy, distribute, transmit, and adapt the work in any
medium, so long as the original work is properly cited. After this work has been published by Sciyo,
authors have the right to republish it, in whole or part, in any publication of which they are the author,
and to make other personal use of the work. Any republication, referencing or personal use of the work
must explicitly identify the original source.
Statements and opinions expressed in the chapters are these of the individual contributors and
not necessarily those of the editors or publisher. No responsibility is accepted for the accuracy of
information contained in the published articles. The publisher assumes no responsibility for any
damage or injury to persons or property arising out of the use of any materials, instructions, methods
or ideas contained in the book.
Publishing Process Manager Iva Lipovic
Technical Editor Martina Peric
Cover Designer Martina Sirotic
Image Copyright Yellowj, 2010. Used under license from Shutterstock.com
MATLAB® (Matlab logo and Simulink) is a registered trade mark of The MathWorks, Inc.
First published September 2010
Printed in India
A free online edition of this book is available at www.sciyo.com
Additional hard copies can be obtained from publication@sciyo.com
Matlab - Modelling, Programming and Simulations, Edited by Emilson Pereira Leite
p. cm.
ISBN 978-953-307-125-1
SCIYO.COM
free online editions of Sciyo
Books, Journals and Videos can
WHERE KNOWLEDGE IS FREE be found at www.sciyo.com
Contents
Preface VII
Chapter 1 Tips and tricks for programming in Matlab 1
Karel Perutka
Chapter 2 Using MATLAB to develop standalone graphical
user interface (GUI) software packages for educational purposes 17
A. B. M. Nasiruzzaman
Chapter 3 Teaching practical engineering for freshman students
using the RWTH – Mindstorms NXT toolbox for MATLAB 41
Alexander Behrens, Linus Atorf and Til Aach
Chapter 4 A student friendly toolbox
for power system analysis using MATLAB 67
A. B. M. Nasiruzzaman
Chapter 5 A Matlab® interactive tool for computer aided
control systems design in frequency domain: FRTool 87
Robin De Keyser and Clara Ionescu
Chapter 6 MATLAB – based software for modeling
and studying grid – tied photovoltaic systems 99
Ali Assi and Mohammed Abdi Jama
Chapter 7 Modelling of DC-DC converters 125
Ovidiu Aurel Pop and Serban Lungu
Chapter 8 Matlab simulations
for power factor correction of switching power 151
Ren Kaichun, He Chunhan, Su Dan, Wang Yongli, Zhang Xingqi, Liu Xiaojun,
Gong Lihong, Zhao Ying and Liu Peng
Chapter 9 Simulation of numerical distance relays 171
Dr. Hamid H Sherwali and Eng. Abdlmnam A. Abdlrahem
Chapter 10 Evaluation of the Delta-Sigma modulator
coefficients by MATLAB parallel processing 193
Michal Pavlik, Martin Magat, Lukas Fujcik and Jiri Haze
VI
Chapter 11 A Matlab/Simulink Framework for PLC Controlled Processes 211
João Martins, Celson Lima, Herminio Martínez and Antoni Grau
Chapter 12 Optimization and Scheduling Toolbox 239
Michal Kutil, Přemysl Šůcha, Roman Čapek and Zdeněk Hanzálek
Chapter 13 Designing antenna arrays using signal processing,
image processing and optimization toolboxes of MATLAB 261
Joseph Sahaya Kulandai Raj and Joerg Schoebel
Chapter 14 Analysis, model parameter
extraction and optimization of planar inductors using MATLAB 277
Elissaveta Gadjeva, Vladislav Durev and Marin Hristov
Chapter 15 Modelling and simulation
of processes from an iron ore sintering plants 301
Corina Maria Diniş
Chapter 16 Fired process heaters 327
Hassan Al-Haj Ibrahim
Chapter 17 Finite difference solutions of MFM square
duct flow with heat transfer using MatLab program 365
Mohammed Al-Khawaja and Mohamed Selmi
Chapter 18 Toolbox for GPS-based attitude
determination: An implementation aspect 389
Zhen Dai, Stefan Knedlik and Otmar Loffeld
Chapter 19 Seismic model-based inversion using Matlab 405
Emilson Pereira Leite
Chapter 20 Computational and mathematical methods
in portfolio insurance - A MATLAB-based approach 413
Vasilios N. Katsikis
Preface
During the last decade the use of MATLAB® has been consistently increasing in scientific
academic institutions as well as in several branches of industry that deal with topics ranging
from economics to spacecraft orbit simulations. This software package has been proved to be
very efficient and robust for numerical data analysis, modelling, programming, simulation
and computer graphic visualization.
This book is a collection of 20 excellent works presenting different applications of several
MATLAB® tools that can be used for educational, scientific and engineering purposes. Most
of the authors have been working with MATLAB® for several years and are recognized
experts in their fields.
Chapters include tips and tricks for programming and developing Graphical User Interfaces
(GUIs), power system analysis, control systems design, system modelling and simulations,
parallel processing, optimization, signal and image processing, finite different solutions,
geosciences and portfolio insurance. Thus, readers from a range of professional fields can
benefit from the content of this book.
I would like to thank the authors for spending a significant part of their time and efforts
to complete each chapter, providing high-quality information for world-wide readers. Also,
I must say that the very well organized Sciyo on-line system had significantly facilitated
making chapter revisions and organizing them, as well as keeping track of deadlines, in order
to have this book developed in the most timely and efficient way. Therefore, I thank the Sciyo
team, including the Editorial board, for their support and for accelerating the whole process
of writing of this book.
Editor
Emilson Pereira Leite
Institute of Geosciences – University of Campinas
Brazil
Tips and tricks for programming in Matlab 1
Tips and tricks for programming in Matlab
1
X
Karel Perutka
Tips and tricks for programming in Matlab
Karel Perutka
Tomas Bata University in Zlin, Faculty of Applied Informatics
Czech Republic, European Union
1. Introduction
Matlab is the software developed by the MathWorks, Inc., Natick, USA. In 1984, the first
version appeared. Software was primarily used only for the mathematical computation
enabling the computation of complicated matrix equations and their systems. All major
functions can directly use the matrix as the input. From that year, the software is still under
development enlarging the area of the users every year. Matlab became the standard in the
area of simulation and modelling and it is used by the researchers and students at
universities mainly in the areas of Control Engineering, Power Plant Systems, Aerospace,
Bioinformatics, Economics and Statistics. In comparison to other software such as
Mathematica or Maple, Matlab has several advantages. Let us mention some. Its open
architecture enables sharing all source code among the user community and several
different areas are solved and the solution appears usually as a new toolbox. Simulink is the
important Matlab enlargement which simplifies the computation very much. You just drag
and drop the blocks to the new window from the block libraries and connect them and run
the model. Matlab is used not only at universities but also in practice, for instance by NASA
or General Motors. Most Matlab users are from the major world countries, such as USA,
Japan, China, and India. Nice book was written by Hanselman and Littlefield (Hanselman
and Littlefield, 2005). And interesting paper about teaching using Matlab was written by
Perutka and Heczko (Perutka & Heczko, 2007). This chapter provides some chosen tips and
tricks to the beginners in Matlab programming and should ease the first steps in
programming. These tips and tricks are based on the experience of chapter author with
teaching Matlab programming in the undergraduate curriculum for several years. The
author mostly worked in MATLAB version 6.5, for which tips are. They are unsorted and
each chapter provides one tip or trick only.
2. Placing picture as dialog background
Being bored from standard look of GUI created in Matlab? If you create dialog in Matlab
using GUIDE or set of functions , , and , the dialog
figure uimenu uicontrol axes
background is usually based on the settings of the system, for example in older Microsoft
Windows it was grey – Windows Classic Theme. However, if you need to have your picture
as the figure background, there is possible to use the following solution. Such example is
2 Matlab - Modelling, Programming and Simulations
shown in figure 1. The dialog in this figure contains only 3 grey pushbuttons ( This code should be placed in the file where the figure is defined. The line 1 of the code is
online
, , ) and background picture. responsible of loading the picture in the Matlab Workspace using the function . In
ident. Gr >> image
What to do first? You have to draw the picture in the extern software, for example in Corel this case, STCssu.jpg is the name of picture file and the picture is loaded to the STCssu
DRAW! and save it in one of the formats that Matlab supports, for instance as JPG or BMP. variable. Line 2 creates the axes with their range just for all dialog area. Command in line 3
You can get the list of supported formats from the Matlab Help Dialog. Don’t forget to write draws the image from the STCssu variable to the axes created by line 2. The axes description
down the width and height of the picture or their ratio. Create new dialog using the is hidden by the command on line 4. If you don’t re-draw the dialog, you can delete the
command or by GUI. Set the size of the new window in accordance with the picture variable from the Matlab Workspace, as it is shown in line 5. But if you re-call the dialog,
figure
width and height or their ratio. How? If you working with GUIDE, double-click the window don’t use line 5. For the dialog re-calling, lines 2 to 4 are enough.
in GUIDE and Property Inspector should appear. Change the Units property on Pixels and
after that change in the Position property the third and fourth value to the width and height
3. Short online help for every object in dialog
of the figure or keep these values in the ratio of the picture you would like to show. If you
created the dialog using figure function in M-file, include in the list of properties Units Imagine the situation depicted in figure 2. There is a short text “If you click this button, you
and Position and set them in similar way as was described for the GUI created by GUIDE. will open the dialog of setting the controller parameters.” in the box. This text is shown if
Now you need to load the figure in the Matlab Workspace, create axes and put the figure you keep the cursor on the button Gr for a while. This might be useful especially in the case
inside them. This tip is based on work of Perutka (Perutka, 2007). Inspire yourself by the of two sorts of objects in dialog (button or edit text) to provide necessary short information
following code which will be commented what should be written as the text (edit text) or what will happen when the button is
pressed. But short information can be displayed over every object in dialog which has the
1
STCssu=imread('STCssu.jpg','jpg'); property TooltipString.
2
axes('Position',[0 0 1 1]); If you created your dialog by GUIDE, open it in GUIDE again and double click the object for
3
image(STCssu); which you would like to create the short help.
4
axis off;
5
clear STCssu
Fig. 2. Dialog with short help
Fig. 1. Dialog with picture as its background