Table Of Contents (click for easy navigation)

## Introduction to 3D Plots

Following from our theme of the “Matrix”, graphical representation of data is about to take on a whole new dimension. If you are involved in any scientific, technological or managerial field, it will be important for your data to be presented in a graphical format at some point in your tenure. Graphs allow us to visualize the progression of our systems per unit time. Whether you’re a Chemical Engineer in the process of designing a crystallizer for a critical batch process, or a biologist attempting to project the growth rate of a modified cell culture detailed graphical representation of the different variables that are changing with time, is best accounted for via a graph. While data is lovely, once it’s converted into information, that is when the magic will really begin.

3-D plots or surface plots, are graphs that take advantage of the three-dimensional domain. Three sets of data are noted in a synchronized sequence. The data will be combined in order to associate a functional relationship between the a dependent variable (commonly known as Y), as well as two independent variables (X and Z for the purposes of this tutorial). In three dimensional space (which sounds so much more exciting than your standard X versus Y plots) a two dimensional grid is constructed, and the combined Y value for these variables is then calculated as a weighted average. From the collected pool of data, a plot is generated and further mathematical manipulations can be facilitated.

Applications of the 3-D plot for those who want to really encourage themselves to use the plots include:

- 3-D Mapping of the Steam Tables: Every Chemical Engineer in their training undergoes the phase analysis process for activities such as Separations Process Design. Along the journey, for those engineers who delve into the power and process design aspect of life…are the generally dreaded steam tables!! Instead of sitting for hours pouring over the Perry’s or going online to find a calculator for your pressure, entropy, and temperature calculation, tools like MATLAB allow you to model the tables, enter pools of data, and determine the necessary outcomes. Using a system like MATLAB’s, allows the user to engage more with the content, and gamify the process of learning something that usually is a laborious and monotonous task.
- 3-D Mapping in Aerospace Applications: Just last year, the Falcon Heavy by SpaceX was launched. The project took years in the making in order to identify the optimum design of the system. Through that one technological breakthrough, many young scientists and engineers have been encouraged to focus on the stars, Mars and beyond. Using MATLAB, a series of 3-D plot function data suitable for aeronautical use, that enables coordinate analysis of various trajectories in space, aiding marine navigation via satellites and GPS, all are possible via this technology.

With the possibilities as endless as they are, let’s jump into the process of turning the theory into reality. For the purposes of this tutorial, the MATLAB version R2018b was used. Do enjoy!

## What is MATLAB 3D Plot?

The MATLAB 3-D plot is that function in MATLAB that enables the user to develop 3-D plots of two independent variables, and how they correlate to a third dependent variable. Once the data is collated, via a series of mathematical manipulations such as mathematical regressions can be facilitated, in order to assess varying rates of change of systems. Additionally, once a system has been modeled in MATLAB, it will be possible for the user to create a multitude of changes, and propose system design changes that allow the system to be optimized.

## Brief Tutorial of MATLAB 3D Print

For the purposes of the tutorial, we will start with a fresh command page, which is the first screen that crops up once the system has been actualized. MATLAB has a series of ribbons that the user can take advantage of during the process of coding in the MATLAB User Environment, but for the most part, as users we will focus on the Matlab Command Window (that large window to the right of the MATLAB screen). From here, the rest of the system manipulations can be taken advantage of.

The MATLAB system enables the user to create a multitude of 3-D surface plots, that allow the user to assess the system from a multitude of dimensions. The first of the series that we will focus on is the Mesh plot.

### Mesh Plot Generation

The mesh function is one that creates a surface function in a grid-like format. The presentation will be such that the color of the mesh, is integrated with the surface height, so that appropriate demarcation can be determined. Let us use the first example from the MATLAB workbook for a demonstration. We will enter the code:

**z =
peaks(25); ….(1)**

**figure**

**mesh(z)
…(2)**

The first line of code is the equation for the surface plot. The second portion of the code is the portion that is denoting that the generated figure is a mesh plot. Later in the tutorial, we will be able to change the surface visuals. The code in the MATLAB R2018b environment is as follows:

The figure associated with this plot is shown below:

From the mesh, we can optimize the graphical output further, in order to create a surface plot. Using the following syntax, which denotes the surface plot of z, and also indicates a color map formation, the following is the code for the surface map:

Generation of a surface map in MATLAB:

**surf(z)**

**colormap(jet) ****% change color map**

The new code is added to the original code used to develop the surface map:

The associated figure that is generated by MATLAB after pressing enter is as follows:

### Generation of a Surface Plot with Shading

Another iteration of the surface plot, is via the utilization of a surface plot, that focuses on simple color changes with the surface plots that are generated. Adding the following code to our initial sequences, allows us to generate an output that’s in a color such as pink.

**surfl(z)**

**colormap(pink) ****% change color map**

**shading interp % interpolate colors across lines and faces**

## CONCLUSIONS

Feel free to get creative in your output flow. Graphical representation of your data is about to take on a whole new dimension, if you allow MATLAB to be the vehicle of your choice. If you are involved in any scientific, technological or managerial field, the lessons above will be worth the investment of time, for learning how your data can be presented in a graphical format at some point in your tenure. Using these outputs presentations in scientific papers will be something that you can validate.

As outlined above, graphs allow us to visualize the progression of our systems per unit time. Whether you’re an Electrical Engineer in the process of designing a next generation computer chip, or a bio-engineer attempting to project the stresses and strains of mechanical leg…it will be possible for you to model these representations in the MATLAB system. While data is lovely, once it’s converted into information, that is when the magic will really begin. Do jump in and explore!!

With the possibilities as endless as they are, keep practicing in order to achieve your goals!!

**Reference
Articles: **

3-D plots: https://ncss-wpengine.netdna-ssl.com/wp-content/themes/ncss/pdf/Procedures/NCSS/3D_Surface_Plots.pdf

Mathworks Workbook: https://www.mathworks.com/help/matlab/visualize/creating-3-d-plots.html

Tandose Sambo is a Chemical Process Engineer, with a focus on improving process efficiency via operational improvements. Six-Sigma certified, and with a Design-focus and Data Analytics interest, she is a driven growing entrepreneur, with the intention to optimize industrial and business process operations. Her interests include sharing time with family and travelling.