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

Conversion of Floating Point Numbers in Matlab

In the last post on floating point numbers, I presented a brief overview of floating point numbers, introduced several Matlab functions that provide information about floats (realmin, realmax, and eps), and explored the workings of eps. In this post, I would like to introduce a function that I wrote in Matlab to convert a floating point number to its binary representation and use that function to explain the floating-point representations of ten different numbers.

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

Floating Point Numbers in Matlab

Floating point numbers are utilized in most calculations performed in Matlab and other programming languages. Often misunderstood, floating-point arithmetic can cause many confounding problems in addition, subtraction, multiplication, division, comparison, and other types of calculations. In this series of posts, I would like to describe the basics of floating point numbers that conform to  IEEE Standard 754 , introduce several Matlab functions that provide information about floating point numbers, provide a pair of functions that convert between the decimal and binary floating point representations, present some examples of how to view floating point numbers in different formats, and demonstrate how to handle some common problems with their arithmetic. In this post, I will give a brief overview of floating point numbers, introduce several Matlab functions that handle floats, and delve into detail of one of these functions named eps.

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

How to Blur an Image with a Fourier Transform in Matlab – Part I [Revised*]

In the last post, many moons ago, I introduced the 2-D FFT and discussed the magnitude and phase components of the spatial Fourier domain.  In the next few posts, I would like to describe a concrete application of the 2-D FFT, namely blurring.  Blurring and deblurring are useful image processing techniques that can be used in a variety of fields.  I will explain what blur is mathematically and how it is performed artificially.  In future posts, I’ll go into more depth about what happens in the spatial domain, different types of blur, and some current deblurring technology.

Continue reading

Modeling with ODEs in Matlab – Part 4A

It’s finally time for Part 4! Now that we know how to design and numerically solve simple ODE models it’s time to take a look at how to fit these models to empirical data. It is important to remember that we design models to simulate real behavior. Thus, it is important to be able to tie our ODE equations to the real system we are trying to model. We do this by choosing values for our model parameters that makes the system behave similar to real world behavior. This lesson continues in Part 4B.
Continue reading