简体   繁体   中英

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

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

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM