Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab 3D Matrix Plot [duplicate]

Ive created a 3d matrix in MATLAB. The values of the matrix are the velocity at that point in a rectangular section. I would like a plot with colours showing the values at each position, is this possible?

Phrasing this another way, I have a matrix of size 100x100x200. Id like a graph that has 100x100x200 points and the colour of each of those points is related to its value.

like image 435
dojogeorge Avatar asked Feb 22 '12 13:02

dojogeorge


People also ask

Can we multiply 3D plot in Matlab?

Can we have multiple 3d plots in MATLAB? Explanation: The plot3() function is a pre-defined function in MATLAB. So, it will allow the use to generate multiple 3d plots.

How do you repeat a plot in Matlab?

If you use 'hold on', you should then be able to plot on the same figure, then simply use the 'hold off' function when you're done plotting on the same graph.


1 Answers

This question is very similar to this question. You might want to check it out.

UPDATE:

Suppose you have a 3D matrix A:

A = rand(100,100,200);

You want to plot each entry of A mapped to a color at its 3D coordinates. First generate the coordinates:

[x,y,z] = meshgrid(1:100,1:100,1:200);

Now you are ready to use scatter3:

scatter3(x(:),y(:),z(:),5,A(:))

Here the : indexing vectorizes the coordinates column-wise.

Hope this helps.

like image 147
upperBound Avatar answered Nov 04 '22 04:11

upperBound