## Symbolic Integration and Differentiation using MATLAB

While messing with MATLAB during free time I have found the method (thanks to MATLAB documentation) of performing symbolic integration and differentiation using MATLAB. And also the proper way to display a function in MATLAB command line. In this small article I am going to share my experience on symbolic integration and differentiation using MATLAB.

### Representing a function as reader friendly format

Take an example function f(x) as,

We can input our function to MATLAB as follows.

You can clearly see that ‘x’ is a symbolic object and f(x) is a symbolic function. Say If you need to evaluate f(x) at x = 10; that is f(10) then it’s simply;

However this equation and answer representation is bit annoying. Therefore by using the command * ‘pretty’ *we can display this in more readable format in MATLAB command line.

Now let’s have a look how the symbolic differentiation is performed.

## Process spatial operations without ‘for’ loops in MATLAB

While working on some image enhancement applications which the intensity of a given pixel is also a function of its location (spatial coordinates), I used to use ‘for’ loops to iterate each pixel at once and calculate its intensity based on (x,y) value obtained from those two ‘for’ loops. This is very annoying since it takes quite some time to process two ‘for’ loops as well as it is a belief that the MATLAB ‘for’ loops are used to slow. In this article I share my experience how I avoided the requirement of two ‘for’ loops by using the properties of complex numbers for a photo effect which I described in a previous article of mine.

Normally in an image there is an mxnx3 matrix which represents red, green and blue intensities respectively. In my case I append another 4^{th} matrix of coordinates which makes the image matrix as mxnx4. (Even-though there is a memory drawback in this design, it is very easy to handle rather than two nested ‘for’ loops).

This 4^{th} matrix contains complex numbers which their real value is equal to row index and its imaginary value is equal to its column index. And now we do have another advantage. Using the properties of complex numbers we can easily calculate the distance and angle between two pixels in interest which is very useful in image effects such as ‘focal BW’.

## Serial PORT MATLAB – Getting Started

Serial port is a physical communication interface which transfer one bit at a time in contrast to parallel port. In the recent past, before USB serial port communication is the most famous communication medium for many computer peripherals such as mouse, keyboard, Etc. Still in many embedded development environments use serial port communication as data transmission interface.

When it comes to my field of interest, where developing embedded systems, mostly signal processing applications, I wanted to visualize and to do some tweaks to processed data to verify whether my application works properly or not. In this case normal serial port desktop applications does not allowed me to visualize what I needed except the application ‘Serial Chart’. Therefore as usual I ended up with a MATLAB solution that is serial port communication with MATLAB. In this article I will share my experience in sending data and receiving data with interrupts in serial port with MATLAB.

## Photo Effects using MATLAB 3.0 – Image warping using MATLAB – Fisheye Similar Effect

The term *fisheye* was coined in 1906 by American physicist and inventor Robert W. Wood based on how a fish would see an ultra-wide hemispherical view from beneath the water (a phenomenon known as Snell’s window) (Wikipedia). I tried several domain transformation functions to create the fisheye effect and ultimately I ended up with warping an image into a circle which gives somewhat similar result to the fisheye effect. In this article I am going to share my experience on warping an image in to a circle (fisheye effect, my version).

Here is an example of correct fisheye effect.

## MATLAB plotting tools 1.0 – ‘plot’ command

Data visualization is a main requirement in Image and Audio signal processing, since it can be used to identify special features, intermediate results, process states as well as the correctness of the final results. Data plotting is one way of data visualization which used in very common by all MATLAB users. However the selection and handling of plot for the requirement is a critical factor since the whole representation of the data is depends on the tool we choose to visualize it. In this article (or maybe a set of articles) I am going to share my experience and suggestions on using MATLAB plotting tools.

### plot Command

The command** ‘plot’** is the most widely used data visualization tool which will create a 2D line plot on a MATLAB figure. Say you are having a data set called** ‘y’** based on values** ‘x’**, you can simply visualize them using the plot command as follows.

x = 0:0.001:100; % x is the array of 0 to 100 with 0.001 intervals y = sin(0.05*pi*x); % y is the sine value array of x plot(y);

After this command plot will be drawn in a MATLAB figure as follows;

## Setting up MATLAB with Atlys Spartan 6 FPGA for Hardware Co-simulation

In my previous articles I discussed how to perform a hardware co-simulation using MATLAB, by using Digilent Atlys Spartan 6 FPGA development kit. But many of my colleagues had the problem of setting up MATLAB for Hardware co-simulation. With a help of a friend of mine, we managed to configure MATLAB for hardware co-simulation. In this short article I am going to share my experience on setting up MATLAB for hardware co-simulation with Atlys Spartan 6 Development Kit.

## MATLAB GUI programming (code level) 2.0 – Undocumented MATLAB – JAVA codes in MATLAB M-files

This is something I found really interesting in MATLAB. We can write m-scripts with JAVA codes, this is very useful when designing UI components for MATLAB applications. In this article I will share my experience on creating GUI in MATLAB using JAVA and also an implementation of video cropping software (backend part will be discussed on my next article).

For more information on Undocumented MATLAB, please visit Undocumented MATLAB official web page.

When using JAVA codes in *.m files we do not use “new” keywords to initiate any objects. I am not sure the usage of import keyword in MATLAB/JAVA. Therefore JFrame must be used as java.swing.JFrame. It is quite different from JAVA.

JFrame frame = new JFrame; // Java Syntax

frame = javax.swing.JFrame; % matlab syntax