Learning to Program with MATLAB Building GUI Tools by Lent

Learning to Program with MATLAB Building GUI Tools by Lent

PDF Free Download | Learning to Program with MATLAB Building GUI Tools by Craig S. Lent.

Preface to Learning to Program with MATLAB

To learn how to program a computer in a modern language with serious graphical capabilities is to take hold of a tool of remarkable flexibility that has the power to provide profound insight.

This text is primarily aimed at being the first course in programming and is oriented toward integration with science, mathematics, and engineering.

It is also useful for more advanced students and researchers who want to rapidly acquire the ability to easily build useful graphical tools for exploring computational models. The MATLAB programming language provides an excellent introductory language, with built-in graphical, mathematical, and user-interface capabilities.

The goal is that the student learns to build computational models with graphical user interfaces (GUIs) that enable exploration of model behavior.

This GUI tool-building approach has been used at multiple educational levels: graduate courses, intermediate undergraduate courses, an introductory engineering course for first-year college students, and high school junior and senior-level courses.

The MATLAB programming language descended from FORTRAN, has evolved to include many powerful and convenient graphical and analysis tools. It has become an important platform for engineering and science education, as well as research.

MATLAB is a very valuable first programming language, and for many will be the preferred language for most, if not all, of the computational work they do. Of course, C++, Java, Python, and many other languages play crucial roles in other domains.

Several language features make the MATLAB language easier for beginners than many alternatives: it is interpreted rather than compiled; variable types and array sizes need not be declared in advance; it is not strongly typed; vector, matrix, multidimensional-array, and complex numbers are basic data types; there are a sophisticated integrated development and debugging environment, and a rich set of mathematical and graphics functions is provided.

While computer programs can be used in many ways, the emphasis here is on building computational models, primarily of physical phenomena (though the techniques can be easily extended to other systems). A physical system is modeled first conceptually, using ideas such as momentum, force, energy, reactions, fields, etc.

These concepts are expressed mathematically and applied to a particular class of problems. Such a class might be, for example, projectile motion, fluid flow, quantum evolution, electromagnetic fields, circuit equations, or Newton’s laws.

Typically, the model involves a set of parameters that describe the physical system and a set of mathematical relations (systems of equations, integrals, differential equations, eigensystems, etc.). The mathematical solution process must be realized through a computational algorithm—a step-by-step procedure for calculating the desired quantities from the input parameters.

The behavior of the model is then usually visualized graphically, e.g., one or more plots, bar graphs, or animations.

A GUI tool consists of a computational model and a graphical user interface that lets the user easily and naturally adjust the parameters of the model, rerun the computation, and see the new results.

The experience that led to this text was the observation that student learning is enhanced if the students themselves build the GUI tool: construct the computational model, implement the visualization of results, and design the GUI.

The GUI is valuable for several reasons. The most important is that exploring model behavior, by manipulating sliders, buttons, checkboxes, and the like encourages a focus on developing an intuitive insight into the model behavior. Insight is the primary goal.

Run- ning the model many times with different inputs, the user can start to see the characteristic behavior of the physical system represented by the model. Additionally, it must be recognized that graphically driven tools are what students are accustomed to when dealing with computers.

A command-line interface seems crude and retrograde. Moreover, particularly for engineering students, the discipline of wrapping the model in a form that someone else could use encourages a design-oriented mentality.

Finally, building and delivering a sophisticated mathematical model that is operated through a GUI interface is simply more rewarding and fun. The GUI tool orientation guides the structure of the text.

Part I (Chapters 1 through 8) covers the fundamentals of MATLAB programming and basic graphics.

It is designed to be what one needs to know prior to the actual GUI building. The goal is to get the student ready for the GUI building as quickly as possible (but not quicker).

In this context, Chapter 4 (matrices) and Chapter 6 (animation) warrant comment. Because arrays are a basic MATLAB data class and solving linear systems a frequent application, this material is included in Part I. An instructor could choose to cover it later without disrupting the flow of the course.

Similarly, the animation techniques covered in Chapter 6 could be deferred. The animation process does, however, provide very helpful and enjoyable practice at programming FOR loops.

Many GUI tools are enhanced by having an animation component; among other advantages, animation provides a first check of model behavior against experience.

The end of Chapter 6 also includes a detailed discussion of the velocity Verlet algorithm is an improvement on the Euler method for solving systems governed by Newton’s second law.

While this could be considered a more advanced topic, without it, models as simple as harmonic motion or bouncing balls fail badly because of nonconservation of energy.

Part II covers the GUI tool created with the GUIDE (graphical user interface development environment) program, which is part of MATLAB. Chapters 9 and 10 are the heart of the text and take a very tutorial approach to GUI building.

Chapter 10 details a simple, but widely useful, a technique for transforming a functioning MATLAB program into a GUI tool. Readers already familiar with MATLAB, but unfamiliar with using GUIDE, can likely work through these two chapters in a couple of hours and be in short order making GUI tools.

Part III covers more advanced techniques in GUI building, graphics, and mathematics. It is not meant to be comprehensive; the online MATLAB help documentation is excellent and will be the main source for many details.

The text covers what, in many cases, is the simplest way to invoke a particular function; more complicated uses are left for the student to explore using the documentation.

This approach—having students write GUI tools for specific problem domains—grew out of the author’s experience teaching undergraduate electromagnetics courses and graduate quantum mechanics courses in electrical engineering at the University of Notre Dame.

These areas are characterized by a high level of mathematical abstraction, so having students transform the esoteric mathematics first into code, and then into visualizable answers, proved invaluable.

The text began as a set of lecture notes for high school students at Trinity School at Green- lawn, in South Bend, Indiana. Since 2005, all Trinity juniors have learned MATLAB using this approach and have used it extensively in the physics and calculus courses that span the junior and senior years.

The two other Trinity School campuses, one in Falls Church, Virginia, and the other in Eagan, Minnesota, adopted the curriculum soon after the Greenlawn campus. The last chapter on mathematics is largely shaped by the material covered in the Trinity senior year.

The author is profoundly grateful to the faculty and students of Trinity Schools, for their feedback, love of learning, and courage.

Special thanks to Tom Finke, the remarkable head of Math and Science for Trinity Schools, and to Dr. John Vogel of Trinity School at Meadow View, for very helpful reviews of the manuscript. All author’s royalties from this text will go to support Trinity Schools. I’m very grateful to Tom Noe and Linda DeCelles for their help in preparing the manuscript.

Since 2010, this approach to learning MATLAB, and the earlier preprints of the text, has been used in the Introduction to Engineering course for first-year students in the College of Engineering at Notre Dame.

In addition to learning to make MATLAB GUI tools, students employ them as part of a semester project completed in small teams.

Each project normally has a substantial physical apparatus (involving significant construction), as well as an associated computational model. Some of the topics of the more specialized graphic included in Part III have been selected because they tend to arise in these projects.

The course includes several other modules in addition to MATLAB and is the creation of Prof. Jay Brockman, a masterful teacher with profound pedagogical insights.

It is worth noting that in both the first-year college engineering and high school contexts, students benefit from a brief experience with a simpler programming language. At Notre Dame, this simpler language is the Lego robotics ROBOLAB® language for programming Lego Mindstorms® robots.

The high school curriculum at Trinity introduces students to programming with a four-week course on the Alice language, developed by Carnegie Mellon University.

These “ramp languages” allow students to become accustomed to programming as creating a sequence of instructions in a way that is insulated from syntax errors.

Learning to Program Contents

MATLAB Programming

  • Getting Started
  • Strings and Vectors
  • Plotting
  • Matrices
  • Control Flow Commands
  • Animation
  • Writing Your Own MATLAB Functions
  • More MATLAB Data Classes and Structures

Building GUI Tools

  • Building a Graphical User Interface
  • Transforming a MATLAB Program into a GUI Tool
  • GUI Components

Advanced Topics

  • More GUI Techniques
  • More Graphics
  • More Mathematics

Download Learning to Program with MATLAB Building GUI Tools by Lent in PDF Format For Free.

Share book:

Related Free Books

Learning to Program with MATLAB Building GUI Tools by Lent

Book Details







Request your PDF Book

Write the name of the book in detail (Name, Author, Edition...)
Click or drag a file to this area to upload.

What's the problem with this file?

Attention !

Help us remove any copyrighted material that may be posted on our site.

We ask you to inform us of any infringing material that may be unintentionally published on our site to remove it.

Reach us at: [email protected]

Attention !

Help us remove any copyrighted material that may be posted on our site.

We ask you to inform us of any infringing material that may be unintentionally published on our site to remove it.

Reach us at: [email protected]