Thursday , March 21 2019

# English-Tutorial-6: PLOTTING in MATLAB-2013a

PLOTTING in MATLAB-2013a:

Plotting: There are two type plot in MATLAB 2D and 3D. For more details about plotting please see http://www.mathworks.com. Now we will see some plotting system with MATLAB. For this go to MATLAB and open editor window in the same way.

Now we will going to run some codes for a simple line plot figure. Now see the codes, after you create this plot with me then I will explain the code and figure.

After type your codes click the Run tool, than the code will be simulate and its output will be showing on figure window. See below the output screenshot.

`clc;`

`clear all;`

`x = 0:0.1:pi;`

`y = cos(x);`

`plot(y);`

`grid on;`

This plot is showing a simple line.

Code explain:

We know the value of pi = 3.1416 and in this codes x = 0:0.1:pi;

Which means the value of x will goes from 0 to 0.1 by 0.1 to 3.1416(pi). You can type this line (x = 0:0.1:pi) of codes in the command window for seen the main result. See the command windows result below,

Now calculate every value of cos(). As like

cos(0) = 1

cos(0.1000) = 0.9950

cos(0.2000) = 0.9801

cos(0.3000) = 0.9553

cos(0.4000) = 0.9211

cos(0.5000) = 0.8776

cos(0.6000) = 0.8253

cos(0.7000) = 0.7648

cos(0.8000) = 0.6967

cos(0.9000) = 0.6216

cos(1.0000) = 0.5403

cos(1.1000) = 0.4536

cos(1.2000) = 0.3624

cos(1.3000) = 0.2675

cos(1.4000) = 0.1700

cos(1.5000) = 0.0707

cos(1.6000) = -0.0292

cos(1.7000) = -0.1288

cos(1.8000) = -0.2272

cos(1.9000) = -0.3233

cos(2.0000) = -0.4161

cos(2.1000) = -0.5048

cos(2.2000) = -0.5885

cos(2.3000) = -0.6663

cos(2.4000) = -0.7374

cos(2.5000) = -0.8011

cos(2.6000) = -0.8569

cos(2.7000) = -0.9041

cos(2.8000) = -0.9422

cos(2.9000) = -0.9710

cos(3.0000) = -0.9900

cos(3.1000) = -0.9991

For every value of cos you need to create every position on a graph paper. Please see this image below me just showing a basic system for learning what this is.

Now I mean you can understood this program. Please do solve many codes with yourself for experience.