Modeling with ODEs in Matlab – Part 5A

We are going to wrap up this tutorial series with a fun exploration of complex systems. Complex systems behave in unpredictable ways. This often makes it difficult to design and use models to examine their behavior. In this lesson we will look at some hallmarks of complex systems and examine a canonical example. Finally, in the next installment we will look at how differential equation models of complex systems can be difficult to examine using numerical solutions.
Continue reading

Modeling with ODEs in Matlab – Part 4B

Welcome to Modeling with ODEs in Matlab – Part 4B! The previous post, Part 4A, introduced the idea of fitting ODE coefficients to empirical data. We saw that proper use of the nlinfit function combined with ode45 or ode15s allows us to fit a model to data when given a good initial estimate of the parameter values. Unfortunately, this approach does not work as well if the initial guess is not within the basin of attraction of the best fit. Today we will look at a new approach to function optimization: Genetic Algorithms (GAs). Genetic Algorithms are part of a search family I like to call “intelligent randomized search”, which also includes techniques such as Simulated Annealing and Particle Swarm Optimization.
Continue reading

Random Numbers in Matlab – Part I

In this series of posts, I will explain how to use the various random number generation functions in Matlab. This will include the usage of the basic commands, how to control random number generation, how to create other distributions from the basic functions that Matlab provides, and what alternatives there are to the functions used in Matlab. In this post, I will explain the basic random number generation commands in Matlab, including randrandnrandi, and randperm, and provide some example applications.

Continue reading

A Blackjack GUI in Matlab – Part IV of using Guide

With this post we wrap up our introduction to using guide with a look at the usage of a push button and a drop-down menu in our creation of a blackjack strategy guide GUI. As a look back, or to catch up, you can visit our three previous posts: Part I: Creating the layout using guide; Part II: Setting up a table; and Part III: getting user input from radio buttons and text boxes. Finally, we have also attached all of the necessary code to the end of this post to do as you please.

Continue reading

Building GUIs in Matlab – Part III Utilizing User Input

In this post we will combine the ideas presented in part I and part II on building a GUI utilizing guide in Matlab. So far we have generated two graphical windows, one of which includes radio buttons, edittable text boxes, a drop-down menu, and a push button, and the second of which has a modifiable strategy table. The object now is to combine the two windows, and allow for proper user control of all of these components.
Continue reading

Building a GUI in Matlab – Part II Tables

Last week we looked at the usage of guide in building a GUI. We included radio buttons, both editable and static text boxes, a drop-down menu and a push button. This week, we’ll create our second GUI to display a table (uitable). As all the decisions in blackjack hinge on two pieces of information: 1) the face up card of the dealer; and 2) the player cards, a look-up table can provide an optimal method for making a simple informed choice of whether to hit, stand, split or double down.
Continue reading

Building a GUI in Matlab using Guide – Part I

Users crave the ability to use graphical user interfaces (GUIs) to perform tasks. While command line input can be beneficial and easier to implement (see our previous post on user inputs), error handling and decision making can be more intuitive through a GUI. Over the next several weeks, we’ll demonstrate the wonderful capabilities of Matlab in creating such GUIs. Using the Matlab built-in GUI building tool guide, we will build a functional program that takes in user inputs and displays useful information. In order to make this exercise fun, we’ll be creating a GUI that provides the optimum strategy for decision making in the game of blackjack.

Continue reading

Sending messages with sendmail

When running long code streams, waiting in front of the computer watching the program run can be excruciating. Sometimes I find myself doing this if I do not know how long the code will run, or if there will be errors returned. (I also sit in front of the computer because I enjoy watching cat gifs and the old school de-fragmentation screens, so who knows…) But you don’t have to! Go out and accomplish something else while your computer chugs away. With the useful command sendmail, we can send messages to our email or phone with some simple commands. Through this post, I’ll share some sample .m files that we commonly use to notify ourselves of code completion or errors.

Continue reading