【发布时间】:2017-05-03 15:08:36
【问题描述】:
MWE 下面
我正在使用 Matlabs surf 函数绘制能量表面。我首先在各种方位角和仰角创建数据点,然后使用通常的球面到笛卡尔方程将这些转换为 (x,y,z) 坐标,并将坐标重新整形为矩阵。
但是,当我绘制此图时,我发现所有数据点都表示为颜色“补丁”的左下角,而不是颜色补丁的中心。
但是,当我缩放表面的半径以反映该点的能量时,由于这种效果,表面上的任何凹坑都会弄乱颜色,即数据的任何对称性都会在可视化中丢失。 I would like this dimple to have roughly symmetrical color around the deepest point here.
显示的示例是从球面坐标到笛卡尔坐标的转换,偏移了两个数据点之间角度差的一半 - 这意味着色块以正确的点为中心,但着色仍然关闭。
有没有办法将色块“居中”在数据采集的确切方向上?
scaling = 100;
min_val = 0.5
count = 1;
azstep = 10;
elstep = 10;
az = 0:azstep:360;
el = -90:elstep:90;
for ii = 1:length(az)
for jj = 1:length(el)
if any(az(ii) == [260 270 280]) && any(el(jj) == [-10 0 10])
r_output(count) = 0.8;
else
r_output(count) = 1;
end
c(count) = r_output(count);
r(count) = 1 + scaling.*(r_output(count)/min_val) - scaling;
x(count) = (r(count)) .* cosd(el(jj)) .* cosd(az(ii));
y(count) = (r(count)) .* cosd(el(jj)) .* sind(az(ii));
z(count) = (r(count)) .* sind(el(jj));
count = count + 1;
end
end
X = reshape(x,length(el),length(az));
Y = reshape(y,length(el),length(az));
Z = reshape(z,length(el),length(az));
C = reshape(c,length(el),length(az));
figure
hold on
surf(X,Y,Z,C)
colorbar
axis equal
xlabel('X axis'); ylabel('Y axis'); zlabel('Z axis');
【问题讨论】: