Blogger news

Saturday, 12 July 2014

Ploting in MATLAB

Three-dimensional plots typically display a surface defined by a function
in two variables, z = f (x,y).
To evaluate z, first create a set of (x,y) points over the domain of the function
using meshgrid.
[X,Y] = meshgrid(-2:.2:2);
Z = X .* exp(-X.^2 - Y.^2);
Then, create a surface plot.
surf(X,Y,Z)




for sub plot:
Subplots
You can display multiple plots in different subregions of the same window
using the subplot function.
For example, create four plots in a 2-by-2 grid within a figure window.
t = 0:pi/10:2*pi;
[X,Y,Z] = cylinder(4*cos(t));
subplot(2,2,1); mesh(X); title('X');
subplot(2,2,2); mesh(Y); title('Y');
subplot(2,2,3); mesh(Z); title('Z');
subplot(2,2,4); mesh(X,Y,Z); title('X,Y,Z');

No comments:

Post a Comment