Blog

Mapping the World’s Flight Routes

Mapping the World’s Flight Routes

Why? I find global flight path maps mesmerizing. In a single image these maps present the vastness of our interconnected civilization on a global scale. These maps are by no means rare. However, they can be a fun programing exercise to generate. Where to get flight data? OpenFlights.org has assembled several databases relate to air travel. Their database on air routes and airportsĀ provided the necessary information to determine flight paths. The database contains nearly 60,000 routes from 3200 airports. Flight…

Read More Read More

Creating AVI Videos in MATLAB

Creating AVI Videos in MATLAB

This video will demonstrate how to make a simple AVI video file of a MATLAB plot. The following functions will be essential for this tutorial: VideoWriter – This function create the video file. The input to the function is the video name. getFrame – This function captures the current state of the figure which is to be written as a frame to the video file. writeVideo This function write the capture frame to the video file. I will also persistent…

Read More Read More

Weather Forecast

Weather Forecast

Getting the Current Weather Conditions First, we will start off by using the Weather API to get the current weather conditions. This data will be obtained in a json format and read with the webread function. The webread function will return the data in a structure format. The current weather conditions are stored as strings and numbers, so some formatting is required: The previous code will write the current weather conditions to the display window in the following style: Houghton,…

Read More Read More

Shapefiles in MATLAB

Shapefiles in MATLAB

A shapefile is a standard geospacial data format for storing location, shape, and attributes of geospacial features. The mapping toolbox in MATLAB has tools for working with these datasets. In this tutorial we will work with some of this functionality. Shapefiles are typically composed of very large datasets. Shapefiles are actually composed of multiple required files that are shared in a compressed *.zip format. The three required files are: *.shp – The main file that stores the geometry *.shx –…

Read More Read More

Using ODE45 to Solve a Differential Equation

Using ODE45 to Solve a Differential Equation

Introduction For this tutorial, I will demonstrate how to use the ordinary differential equation solvers within MATLAB to numerically solve the equations of motion for a satellite orbiting Earth. For two-body orbital mechanics, the equation of motion for an orbiting object relative to a much heavier central body is modeled as: Where Ī¼ is the gravitational parameter of earth (398600 km3/s2) The state-space representation of this equation becomes: MATLAB has many ODE solvers available for the coder. The selection of…

Read More Read More

Removing Items for Plot Legends

Removing Items for Plot Legends

In this tutorial, an object will be removed from a plot legend with the use of the hasbehavior command. Often when creating plots, annotations or trivial lines may be included which can be distracting when included on a legend. For this tutorial, an RLC circuit is simulated and a shaded region is included ± 0.1 A to communicate a convergence region. We will remove this shaded region from the plot legend while keeping the object on the plot. For the…

Read More Read More

Creating Animated Plots in MATLAB

Creating Animated Plots in MATLAB

This tutorial will demonstrate how to create animated plots using MATLAB. This will be demonstrated through the use of a Fourier approximation of a square wave. The infinite series representing the Fourier approximation of a square wave is:     We will now create an animated GIF showing the first 20 terms in this Fourier approximation. For this plot, the only information that changes for each series in title and the y-data for the Fourier approximation. This can be handled…

Read More Read More

Solving the Traveling Salesman Problem Using the Google Maps API

Solving the Traveling Salesman Problem Using the Google Maps API

The full source code for this problem will not be posted since my intent is not to write work that can easily be used in its entirety as a course project. If you are a course instructor and would like to use this as a demonstration, feel free to contact me with your request through your university email account. Determining the distance between cities Introduction Using the Google Maps API, the driving distance, driving time, and GPS locations of each…

Read More Read More