Introduction: How to Plot 3D Graphs in MATLAB

In this tutorial you will learn how to use plot 3D graphs in MATLAB program from MathWorks also

creating a script file that will make a set of data and plot that data.

This is a very useful tool in all types of scientific and math based research allowing the user to take experimental data and look create a visual picture of things like position or velocity vs. time, or even fuel economy of a car over some distance.MATLAB by MathWorks is a computational tool used by many engineers, scientists, and mathematicians to analyse data and present their results in the form of numbers, images, or even video. The program uses matrix algorithms and a unique coding language that allow the user to work with massive systems of equations easily and efficiently. The program also has the power to do numerical evaluations when simple calculus can not be used.

Some time it become very important to analyzes the things from their graphs / visualizations

MATLAB allow you to plot the 2d 3d graphs of your desired data / Equations / Functions ....

A very basic formula all you know is SQUARE OF (A^2+B^2) but when you know their 3d pattern ...its amazing

Just Follow these Instructions

DONT FORGET TO FOLLOW ME ON INTRUCTABLE FOR FURTHER POSTS...

A STEP BY STEP INSTRUCTION IS ALSO GIVEN IN THE BELOW VIDEO LINK .....

Step 1: Opening MATLAB PROGRAM

To complete this instructable you will need a computer, and the MATLAB software from MathWorks.
This task should take between 5 and 10 min to be fully complete.

Step 2: Creating Script File

The easiest way to complete a task in MATLAB is to work in a script file. A script file is a secondary window that allows the user to edit and run a block of code all at one time completing several tasks simultaneously. To open a script file click on the button in the top left corner that says "New Script," (pictured above) for users with older versions of MATLAB this can be done by going to the file tab, selecting new then selecting script. Doing this opens a blank script file in a new window. Note that any commands given in the next several steps must be followed exactly. Any spelling, mis-capitalization, or missing lines will cause the code to crash, so please read the instructions carefully and type the code exactly as it is shown.

Step 3: Clear Screen

When first starting a new script file it is important that you do not have any of the variables that are about to be used assigned to another task. In order to prevent this begin any script file with the following:

clear all

This command clears any values that have been assigned to variables.Also for this particular script you may want to keep the command window on the main window clean. To do this enter the following on the next line your script file:

clc

The "clc" command wipes any previous work from the command window display.

Step 4: Write the CODE / Testing

Write the code in picture OR download the file given at the end .....

Click on the RUN Button

Click on the ADD TO PATH if dialogue box is appear .....

Thats it

IF YOU WANT TO UNDERSTAND MORE ABOUT THE CODING OF MATLAB VISIT THEIR WEBSITE..

Step 5: CODE FILE

clc;

close all;

clear all;

[X,Y] = meshgrid(-8:0.3:8);

R = sqrt(X.^2 + Y.^2) + eps;

Z = sin(R)./R

surf(X,Y,Z);

colormap ;

colorbar;

xlabel('X Axis');

ylabel('Y Axis'); zlabel('Y Axis');

Comments

About This Instructable

1,186views

27favorites

License:

Bio: Studying Electrical Engineering.;-)
More by afzalrehmani:How to Plot Sine Cosine Wave in MATLABHow to Plot 3D Graphs in MATLABHow to install PROTEUS 8.5 Full
Add instructable to: