Basics of MATLAB Programming
MATLAB is a fourth generation programming language which is effective in numerical simulation and data analysis.
March 18, 2014 (Newswire.com) - MATLAB is used to perform numerical computations in complex problems. It is generally a matrix based language. Programs written using MATLAB are usually simple and easier to read than C programs.
Using the MATLAB codes, even the complex problems can be resolved in two lines of simple codes. In this programming language, Comments are usually represented using % symbol.
To define the value of x and evaluate operations, following matlab code is written.
% Define the values of x
x = 0:0.01:1;
% Evaluate f
f = x .^ 3 - 6 * x .^ 2 + 3;
Here value of x is defined between the range 0 and 1. And the dot operator represents that each entry of the row matrix x is raised to the power n.And another basic command is plot() which is used to plot the graph of a function of a variable.
And in images and matrices, COLORMAP function is used to change the color mapping say from gray to hue-saturation-value(hsv). This function is applied to a simple spiral pattern with matrix elements as shown below.
Another color map is 'hot' where the color shades ranges from black ,red,yellow and white shades. If you need to produce the plot for the color map then, use the matlab command RGBPLOT.
In MATLAB, there is a specific function named Space matrix display which helps to display the location of image elements pointing to color map entries.
Spy((X==2) | (X==3))
The above code locates the second or third element of the color map from the loaded file.
Categories: Colleges and Universities