makegauss.m

来自「为stanford大学donoho教授所编写的redgit变换源代码。是用c编写」· M 代码 · 共 30 行

M
30
字号
function G = makeGauss(N, a, b, w)
% Make a half-plane Gaussian image of size N by N
% y = ax + b is the division line

if ~exist('w', 'var')
    w = 1;
end

x = linspace(-1,1,N);
y = linspace(-1,1,N);
[X,Y] = meshgrid(x,y);

% Gausssian
G = exp(-w *(X.^2 + Y.^2));

% Half plane
W = (Y <= a*X + b);

% Gaussian-windowed half-plane
G = G .* W;

% Image
imagesc(x,y,G), colorbar
xlabel('x'), ylabel('y')
axis square

% Surface
% figure;
% surfc(x,y,G); 				% surf plot with contour plot
% xlabel('x'), ylabel('y'), zlabel('f(x,y)')

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?