MATLAB:需要做一个四维绘图(3D +颜色/颜色) [英] MATLAB: Need to make a 4D plot (3D + Colour/Color)

查看:3178
本文介绍了MATLAB:需要做一个四维绘图(3D +颜色/颜色)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做一个3D表面,其中颜色将代表第四个变量。我知道冲浪是类似于我需要的,但是不是这样。基本上,我有以下变量:



t = [1:m]



y = n]



a = [1:o]



这些应是三个笛卡尔坐标轴。我也有一个尺寸为mxnxo的变量S,基本上是幅度,前三个变量的函数(即S = f(t,y,a) )。



总而言之,我需要一个形式(t,y,a,S)的图形,其中前三个变量



提前感谢。

div class =h2_lin>解决方案

SCATTER3需要 x y z 和其他分组参数为用于单个系列的相等大小的Nx1个向量或用于M系列的NxM个矩阵。



您有全空间3D数据。要使用相同大小的坐标向量,请使用 MESHGRID (或 NDGRID )function:

  [X,Y,Z] = meshgrid(t,y,a); 

然后您可以使用SCATTER3:

  scatter3(X(:),Y(:),Z(:),[],S(:))

问题是,因为它的完整空间数据scatter3将不会有什么帮助,特别是如果你有很多点。



您可以筛选S变量(例如 idx = S> 0 ),过滤数据。



如果您确实需要可视化所有数据,请查看体积可视化。例如,我可以推荐 SLICE 功能。



EDIT



这里是一个小三维空间散点图$ c> m , n o 等于5) c> S = rand([m,n,o]); scatter3(X(:),Y(:),Z(:),[],S(:),'filled')





EDIT 2



从你的评论到另一个答案,我发现你有32x76050x4矩阵。你可以实际绘制2D切片一次一个。您可以在2D中使用IMAGESC功能,或在3D中使用SLICE功能。



尝试:

  imagesc(S(:,:,k))



或尝试

  slice(S,[],[],1:size(S,3))
阴影flat


I need to make a 3D surface where colour will represent the fourth variable. I know "surf" is SIMILAR to what I need, but that's not quite it. Basically, I have the following variables:

t = [1:m]

y = [1:n]

a = [1:o]

These should be the three Cartesian corodinate axes.

I also have a variable S that is of dimensions m x n x o, and is basically the amplitude, a function of the previous three variables (i.e. S = f(t,y,a)). I want this to be represented by colour.

So to summarize, I need a graph of the form (t,y,a,S), where the first three variables are vectors of unequal sizes and the final variable is a multidimensional array whose dimensions are determined by the first three.

Thanks in advance.

解决方案

SCATTER3 requires x, y and z and other grouping arguments to be equally-sized Nx1 vectors for a single series or NxM matrices for M series.

You have full space 3D data. To make equally-sized coordinate vectors use MESHGRID (or NDGRID) function:

[X, Y, Z] = meshgrid(t, y, a);

Then you can use SCATTER3:

scatter3( X(:), Y(:), Z(:), [], S(:) )

The problem is since it's full space data scatter3 will not be helpful specially if you have a lot of points.

You can probably filter your S variable (something like idx = S > 0), then you can plot filtered data.

If you really need to visualize all the data, look at Volume visualization in MATLAB documentation. I can recommend SLICE function, for example.

EDIT

Here is an example of full 3D space scatter plot for small vectors (m, n, o equal to 5) with S = rand([m,n,o]); scatter3( X(:), Y(:), Z(:), [], S(:), 'filled' )

EDIT 2

From your comments to the other answer I found that you have 32x76050x4 matrix. You can actually plot 2D slice one at a time. you can do it in 2D with IMAGESC function, or in 3D with SLICE function.

Try:

imagesc(S(:,:,k))

where k is a number from 1 to 4 for the 3rd dimension.

Or try

slice(S, [], [], 1:size(S,3))
shading flat

这篇关于MATLAB:需要做一个四维绘图(3D +颜色/颜色)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆