Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

4D visualization in Matlab (Surface and Mesh)

I have four variables, x,y,z,t. I would like to show (x,y,z) in form of a surface such that the color of the surface is determined by t. I want to assign "t" to color bar. Now, color bar is corresponding to z, I want to have it corresponding to "t" my 4th variable.

Thank you for any help

like image 634
Emily Avatar asked Dec 13 '25 02:12

Emily


1 Answers

That's very easy: just use

surf(x, y, z, t)

From the documentation,

surf(X,Y,Z,C) uses C to define color. MATLAB® performs a linear transformation on this data to obtain colors from the current colormap.

Here's an example:

x = linspace(0,pi,50);
y = linspace(0,pi/2,50);
z = bsxfun(@times, sin(x), sin(y.')); %'
t = bsxfun(@minus, x, y.'); %'// example data;
surf(x,y,z,t); %// draw surface
colorbar %// show colorbar

enter image description here

like image 133
Luis Mendo Avatar answered Dec 15 '25 10:12

Luis Mendo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!