Differentiation and Integration in Matlab

Symbolic expressions can allow for the evaluation of equations as shown in a previous post on symbolics. Symbolics can further be used to solve equations that vary with time or with respect to one another. Calculating this change, either as a derivative or integral, can be done implicitly using the functions ‘sym’,’diff’, and ‘int’.
Continue reading

Symbolic expressions and solving linear equations in Matlab

While Matlab is known for its capabilities in solving computationally intensive problems, it is also very useful in handling symbolic expressions, and further solving simple algebraic equations. In this tutorial we will investigate how to represent symbolic variables using the functions ‘sym’ and ‘syms’, solve equations using ‘solve’, and plot solutions to these symbolic expressions. Continue reading

Computation using cellfun

Cell arrays are useful means of holding various types and sizes of information (as are structs). When manipulations or computations need to be performed on all or a subset of values in a cell array, one useful function that can be utilized is cellfun . Similar to other functions such as structfun or arrayfun, cellfun allows you to apply a predefined or user defined function to each element in the array.

Continue reading

The use of findobj and set for graphics properties

After you create a plot in Matlab, you might need to modify the characteristics of the figure. While many options can be specified during the initial plot command, they can easily be modified later as well using plot handles, and the useful functions of ‘findobj’,’get’ and ‘set’. If you are unclear on some of these commands, or need a refreshers, take a look at our tutorial on plotting .

Continue reading

Getting user input in MATLAB – the use of input, ginput and inputdlg

Sorry for the delay in postings, but many of us are in the state of transition, whether its school, weddings or work. As a simple tutorial to get back into the swing of things, let’s look at several different ways of requesting user input in your MATLAB programs. While you will often need to display information to the user, you will have to request data from them as well. There are several options available to you, and we will run through many of them here. The most basic of which is the command line based “input”.

Continue reading

Clustering Part 2: K-means clustering

Clustering data is the act of partitioning observations into groups, or clusters, such that each data point in the subset shares similar characteristics to its corresponding members. Cluster analysis is commonly used in fields that utilize data mining, pattern recognition and machine learning. While MATLAB has several clustering tools included in its arsenal, we’ll take a look at the function kmeans in this tutorial. Following classification of n observations into k clusters, we can use binary classification to investigate the sensitivity and specificity of our clustering.

Continue reading

Clustering Part 1 – Binary Classification

Binary classification is the act of discriminating an item into one of two groups based on specified measures or variables. While previously we have discussed methods for determining values of logic gates using neural networks (Part 1 and Part 2), we will begin a series on clustering algorithms that can be performed in Matlab, including the use of k-means clustering and Gaussian Mixture Models. Prior to doing so, we will discuss how classification is evaluated, primarily through the discussion of sensitivity, specificity and the way to calculate these values through Matlab.

Continue reading

Neural Networks – A Multilayer Perceptron in Matlab

Previously, Matlab Geeks discussed a simple perceptron, which involves feed-forward learning based on two layers: inputs and outputs. Today we’re going to add a little more complexity by including a third layer, or a hidden layer into the network. A reason for doing so is based on the concept of linear separability. While logic gates like “OR”, “AND” or “NAND” can have 0’s and 1’s separated by a single line (or hyperplane in multiple dimensions), this linear separation is not possible for “XOR” (exclusive OR).

Linear separability for OR and XOR logic gates

Continue reading