Showing posts with label plot. Show all posts
Showing posts with label plot. Show all posts

Sunday, 7 August 2016

MATLAB Programming 52 - 3D plots of functions


Three-Dimensional Plots


Three-dimensional plots basically display a surface defined by a function in two variables, g = f (x,y).
As before, to define g, we first create a set of (x,y) points over the domain of the function using the meshgrid command. Next, we assign the function itself. Finally, we use the surf command to create a surface plot.

The following example demonstrates the concept:


Use the peaks function to define X, Y, and Z as 25-by-25 matrices. Then, create a surface plot.



[X,Y,Z] = peaks(25);

figure
surf(X,Y,Z);


surf creates the surface plot from corresponding values in X, Y, and Z. If you do not define the color data C, then surf uses Z to determine the color, so color is proportional to surface height.




Thursday, 4 August 2016

MATLAB Programming 48 - plot a graph


To plot the graph of a function, you need to take the following steps:


Define x, by specifying the range of values for the variable x, for which the function is to be plotted

Define the function, y = f(x)

Call the plot command, as plot(x, y)

Following example would demonstrate the concept.

Let us plot the simple function y = x for the range of values for x from 0 to 100, with an increment of 5.


Create a script file and type the following code:


x = [0:5:100];
y = x;
plot(x, y)

When you run the file, MATLAB displays the following plot:







Saturday, 21 May 2016

MATLAB Programming 4 - Basic metrix operations

In this section, let us discuss the following basic and commonly used matrix operations:

Addition and Subtraction of Matrices

Division of Matrices

Scalar Operations of Matrices

Transpose of a Matrix

Concatenating Matrices

Matrix Multiplication

Determinant of a Matrix

Inverse of a Matrix

Addition and Subtractions of matrix

Click Here To Watch Video..!

MATLAB Programming 3 - plotting graph

To plot the graph of a function, you need to take the following steps:

Define x, by specifying the range of values for the variable x, for which the function is to be plotted

Define the function, y = f(x)

Call the plot command, as plot(x, y)

Let us plot the simple function y = x for the range of values for x from 0 to 100, with an increment of 5.

Click Here To Watch Video..!