2016-06-09 36 views
0

我需要在MATLAB中繪製具有相位信息的複合函數。爲此,我已經ploted用X,Y表示實部和虛表示的大小和顏色取決於相位,高度的衝浪情節如下所示日誌(X)的例子:如何在MATLAB中使用相位信息繪製複雜函數亮度

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

這作品,但劇情的特點是非常難以看到的。我希望將該功能的高度繪製爲亮度。有沒有辦法做到這一點?

+0

你試過beta = 1; 增亮(h,beta)? – Umar

回答

1

這樣做的一種方法是使用magnitude值的倒數作爲AlphaData,這會導致更高的值變得更輕(更透明,後面有白色軸),而更低的值變得更暗(更不透明) 。

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

enter image description here

如果您有其他情節的對象,不能依靠的是透明度,可以改爲手動白色抖動的顏色。

% 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])); 

這就是說,我不確定這是否使它更容易看到發生了什麼。也許可以考慮製作兩個地塊,一個用於大小,另一個用於階段。

enter image description here

+0

嗨,非常感謝您的建議,但不幸的是,這種解決方法在我需要的情況下無法正常工作(我的錯,沒想到我不會提供更多的例子),我正在繪製多個在一個陰謀中的功能,使其透明不會改變亮度,它只會使其能夠看到下面的其他功能。 – Jack

+0

@Jack更新爲基於抖動的方法。 – Suever

+0

非常感謝,完美的工作。 – Jack