Plotting in MATLAB
The MATLAB graphics system consists of high-level commands for two-dimensional and three-dimensional data visualization, image processing, animation, and presentation graphics. It also includes low-level commands that allows to fully customize the appearance of graphics as well as to build complete Graphical User Interfaces. Given below is a code for plotting a Parabola:
x = 0:0.5:10;
%Indicates that x varies from 0 to 10 with intervals of 0.5
y = x>^2;
%Indicates that square of each element in x is stored in y
plot(x, y)%plotting x and y
xlabel(X)%naming x axis as x
ylabel(Y)%naming y axis as y
title('Graph of y=x^2')%Title of the graph
This code will give the following graph:
You can change the color of the graph by adding another statement in the plot command. For example, plot(x, y, ‘r’) will give the graph line in red. Graphs such as sine, cosine and other trigonometric functions’ curve can also be plotted. The code for sine curve is given below:
x = 0:pi/100:2*pi;
y = sin(x);
plot(x, y, ‘g’)%Will give the graph line in green.MATLAB is a very user friendly language and it is also easy to understand.It’s library is equipped with functions that help us perform a variety of mathematical functions.
Introduction to MATLAB
MATLAB stands for Matrix Laboratory. It is a high-performance language that is used for technical computing. It was developed by Cleve Molar of the company MathWorks.Inc in the year 1984.It is written in C, C++, Java. It allows matrix manipulations, plotting of functions, implementation of algorithms and creation of user interfaces.
Contact Us