如何在 MATLAB 中使用亮度绘制具有相位信息的复杂函数

How Can I Plot a Complex Function With Phase Information in MATLAB With Brightness

我需要在 MATLAB 中绘制具有相位信息的复杂函数。为此,我绘制了一个冲浪图,其中 x、y 代表实部和虚部,高度代表幅度和颜色取决于相位,如下面的 log(x):

示例所示
xmin=-5;
xmax=5;
dx=0.1;
xReal = xmin:dx:xmax;
xImaginary = xmin:dx:xmax;
[x,y] = meshgrid(xReal, xImaginary);
s = x + 1i*y;
z=log(s);
magnitude = abs(z1);
Phase = angle(z);
figure;
h(1) = surf(x,y,magnitude,Phase,'EdgeColor','none');
xlabel('Real');
ylabel('imaginary');
legend('Magnitude');

这可行,但是情节的特征很难看清。相反,我希望将函数的高度绘制为亮度。有办法吗?

一种方法是使用 magnitude 值的倒数作为 AlphaData,这会导致更高的值更亮(更透明,后面有一个白色轴)和较低的值更暗(更不透明)。

h = surf(x, y, zeros(size(magnitude)), 'EdgeColor', 'none');
set(h, 'FaceColor', 'flat', 'CData', Phase, 'FaceAlpha', 'flat', 'AlphaData', -magnitude);
view(2);

如果您有其他绘图对象并且不能依赖透明度,您可以改为使用白色手动对颜色进行抖动处理。

% Determine the RGB color using the parula colormap
rgb = squeeze(ind2rgb(gray2ind(mat2gray(Phase(:))), parula));

% Normalize magnitude values
beta = magnitude(:) / max(magnitude(~isinf(magnitude)));

% Based on the magnitude, pick a value between the RGB color and white
colors = bsxfun(@plus, bsxfun(@times, (1 - beta), rgb), beta)

% Now create the surface
h = surf(x, y, zeros(size(magnitude)), 'EdgeColor', 'none');
set(h, 'FaceColor', 'flat', 'CData', reshape(colors, [size(magnitude), 3]));

话虽这么说,但我不确定这是否可以让您更轻松地了解正在发生的事情。也许考虑只画两张图,一张是幅度图,一张是相位图。