Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

3d plotting of a 2d matrix in matlab

Tags:

plot

matlab

I have an MxN matrix, Z, and some variable h. This matrix represents the points to a solution of a function f(x,y). h is the spacing between points. For instance:

Z(x/h,y/h) = (some value in the Z direction), where x and y are some multiple of h

The domain is from 0 to M*h and the range is from 0 to N*h. I would like to make a 3d representation of the solution defined by the matrix. The graph should be similar to what is produced using the pdetool. How do I do this in Matlab?

like image 516
user972276 Avatar asked Oct 10 '12 20:10

user972276


People also ask

How do you plot a 3D plot in MATLAB?

plot3( X , Y , Z ) plots coordinates in 3-D space. To plot a set of coordinates connected by line segments, specify X , Y , and Z as vectors of the same length. To plot multiple sets of coordinates on the same set of axes, specify at least one of X , Y , or Z as a matrix and the others as vectors.

Which command is for plotting a 3D surface in MATLAB?

surf( X , Y , Z ) creates a three-dimensional surface plot, which is a three-dimensional surface that has solid edge colors and solid face colors.

Can you plot a matrix in MATLAB?

Description. plotmatrix( X , Y ) creates a matrix of subaxes containing scatter plots of the columns of X against the columns of Y . If X is p-by-n and Y is p-by-m, then plotmatrix produces an n-by-m matrix of subaxes.


1 Answers

You can use surf or bar3.

Here is the documentation:

surf: http://www.mathworks.fr/help/matlab/ref/surf.html;jsessionid=c680a6b29a1fa8ff47c120353c12

enter image description here

bar3: http://www.mathworks.fr/fr/help/matlab/ref/bar3.html enter image description here

like image 50
Oli Avatar answered Sep 23 '22 21:09

Oli