Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to visualize an R^3 -> R function in Matlab?

I've got a function that assigns a real value to every point in space. How can I visualize it on some bounded volume?

like image 993
Andreas Avatar asked May 29 '12 16:05

Andreas


1 Answers

To extend Peter's suggestion in the comments ^^:

use scatter3 with setting the cdata parameter:

% generating some sample data
[x,y,z]=sphere(50);
x=x(:);y=y(:);z=z(:);

% the interesting stuff:
h=scatter3(x,y,z);

gives you

scatter3

To add coloring, do the following:

set(h,'cdata',z)

or immediately:

scatter3(x,y,z,'cdata',z);

which results in

enter image description here

Here the color vector is just the z value, but it can be anything (as long as it's the same size as x (and y and z).

like image 59
Gunther Struyf Avatar answered Sep 29 '22 11:09

Gunther Struyf