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

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

问题描述

我需要做一个三维表面,颜色会重新present的第四个变量。我知道,冲浪是类似于我所需要的,但这不是这么回事。基本上,我有以下变量:

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]

t = [1:m]

Y = [1:N]

y = [1:n]

A = [1:O]

a = [1:o]

这些应该是这三个笛卡尔corodinate轴。

These should be the three Cartesian corodinate axes.

我也有一个变量S是尺寸mxnxo,并且基本上是振幅,则previous三个变量的函数(即S = F(T,Y,A))。我想这是由颜色psented再$ P $。

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.

总结一下,我所需要的形式(T,Y,A,S),其中前三个变量是不相等的尺寸的载体和最终变量是一个多维阵列的尺寸由前三个确定的曲线图

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.

在此先感谢。

推荐答案

SCATTER3要求 X 以Z 和其他分组参数是一个系列或N×M的矩阵M系列同样大小的NX1向量。

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.

您有充分的空间三维数据。为了使同样大小的坐标向量使用 MESHGRID (或NDGRID )功能:

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

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

然后你可以使用SCATTER3:

Then you can use SCATTER3:

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

现在的问题是,因为它的全部空间数据scatter3不会有所帮助特别是如果你有一分不少。

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

您也许可以筛选s变量(像 IDX = S> 0 ),那么你就可以绘制过滤后的数据。

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

如果您真的需要可视化的所有数据,看看卷可视化 MATLAB文档。我可以推荐 SLICE 的功能,例如,

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

修改

下面是完整的三维空间散点图小矢量(一个例子<$ C C $> M , N 0 等于5) S =兰特([M,N,O]); scatter3(X(:),Y(:),Z(:),[],S(:),'填补')

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' )

编辑2

从您的意见,以对方的回答我发现你有32x76050x4矩阵。实际上,你可以绘制二维切片一次。你可以用切片的功能做在2D与于imagesc功能,或在3D。

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.

尝试:

imagesc(S(:,:,k))

其中, K 是一个数字,从1到4的第三维。

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

或者尝试

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

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

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