Kenny's Blog

21 Mar 2014

Matlab: A Numerical Approach

Coming from a pure software background, I had a little trouble with MATLAB at first. Now, MATLAB is essentially another frontend a numerical based programming language. There are also numerious libraries out there which provide other langauges with such features, but for the purposes of this post, I’ll just be going over matlab.

Traditionally, functions in Mathematics are continuious. We like continuity in this case. It allows us to symbolicaly reason with things. There are exceptions out there, however. For example, piecewise functions are examples of dealing with discontinuities.

Computers, however, are not continuious. We know that modern digital computers operate in binary. Its not a large jump to say that in a perfect model, computers are essentially a giant state diagram of 1’s and 0’s. Here is the problem! We need some way of interacting with continuous functions in an inheriently discrete environment.

One could argue that the human brain operates on a symbolic level - humans are good at recognizing certain patterns. Modern (digital) computers are not so good at this, but what they are good at, and what humans are bad at, is performing a huge amount of mundane and repeating tasks. What we can do, then, is approximate symbolic functions numerically!

Take this code snippit below, where we define a function y = x:

    % define our step size
    dx = 0.1;

    % define our x term
    x = -5:dt:5;

    % define our function y
    y = x;

    % plot y in terms of x

Here is our result:

matlab plot

Easy enough!