Data Visualization in MATLAB

Dinesh Jinjala
2 min readJun 29, 2019

MATLAB is a great numerical tool to analyze the data. Here are some examples that give you more insight into the graphing capabilities of MATLAB.

First, plot some peaks.

Z = peaks(50);

Let us plot it with surf,

figure; 
h = surf(Z);
view([-60,25]);

Here, view defines the viewing angle. Please visit this page to get more information about the function: view.

MATLAB figure after the execution of the above code.
axis([0 30 0 30 -15 15]);

With the above command, we can see the particular portion of the axis. This will give the result something like this.

Z = peaks(50);
figure;
h = surf(Z);
view(3);
axis on;
xlabel(‘Longitude’);
ylabel(‘Latitude’);
zlabel(‘Altitude’);
title(‘Surface of Peaks’);

Here xlabel, ylabel and zlabel are used to give the labels to a respective axis. “title” is used to give the title to the graph. Above code will give the result like this.

Z = peaks(50);
figure;
h = surf(Z);
view(3);
axis on;
light;
lighting phong;
camlight('left');
shading interp;
colormap(jet(64));
colorbar('vertical');

We can make the graph more realistic image with four lines:

light;
lighting phong;
camlight('left');
shading interp;

light : Create light

lighting : Specify lighting algorithm

shading interp :varies the color in each line segment and face by interpolating the colormap index or true color value across the line or face.

camlight (‘left’):creates a light left and up from camera.

The result of this code will look like this:

This is the image after cam-light, light, lighting, and shading.

We can create even more sophisticated figure and plot using MATLAB. We can create even a video which can show more information about data. Visit this video to get more idea about how MATLAB get to give more intuitive content for presentations.

This is the link of the video: https://youtu.be/udkMIm9vpoE

This is the link for the Github: https://github.com/MachineLearning-Nerd/DataVisualization-in-MATLAB

--

--

Dinesh Jinjala

I am an AI Scientist with interest in painting, playing carom and to do work with awareness.