带有动画的 MATLAB 4D(3d + 彩色)绘图 [英] MATLAB 4D (3d + color) plot with animation
问题描述
我有 3 组 30 个数据点 X、Y、Z.我想制作第四维颜色.然而,我想要使用的第 4 维长度与 X、Y、Z 的长度不同(133 对 30).
这是在 MATLAB 中使用 scatter3 函数时出现的问题,因为颜色维度必须匹配 X、Y、Z 的大小.
我还想以 .avi 格式为这个情节制作动画,并随着电影的进展改变第 4 维(颜色).
提前致谢.
创建一个 2D 或 3D 矩阵来定义您的颜色:如果您使用索引到颜色图中的颜色,则为 2D,如果您想提供 RGB 值,则为 3D.
>
X=1:30;Y=randperm(30);Z=ones(size(X));电压矩阵 = ...;%# 30 乘 133cdata = 电压矩阵;句柄 = scatter3(X,Y,Z);颜色图('喷气')设置(gca,'clim',[min(电压矩阵)最大(电压矩阵)])对于 t=1:size(cdata,2) %# 1 到 133设置(句柄,'cdata',cdata(:,t));暂停(.1)结尾
注意颜色图和轴的clim"属性.
I have 3 sets of 30 data points X,Y,Z. I would like to make the 4th dimension color. However the 4th dimension I want to use is a different length than my X,Y,Z (133 vs 30).
This is a problem when using the scatter3 function in MATLAB, as the color dimension must match the size of X,Y,Z.
I also want to animate this plot in .avi format, and have the 4th dimension (color) change as the movie progresses.
Thanks in advance.
Create a 2D or 3D matrix to define your colors: 2D if you use colors indexed into the colormap, or 3D if you want to give RGB values.
X=1:30;Y=randperm(30);Z=ones(size(X));
voltage_matrix = ...; %# 30 by 133
cdata = voltage_matrix;
handle = scatter3(X,Y,Z);
colormap('jet')
set(gca,'clim',[min(voltage_matrix) max(voltage_matrix)])
for t=1:size(cdata,2) %# 1 to 133
set(handle, 'cdata', cdata(:,t));
pause(.1)
end
Edit: note the colormap and axes 'clim' property.
这篇关于带有动画的 MATLAB 4D(3d + 彩色)绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!