📄 modulate2.m
字号:
function y = modulate2(x, type, center)
% MODULATE2 2D modulation
%
% y = modulate2(x, type, [center])
%
% With TYPE = {'r', 'c' or 'b'} for modulate along the row, or column or
% both directions.
%
% CENTER secify the origin of modulation as floor(size(x)/2)+1+center
% (default is [0, 0])
if ~exist('center', 'var')
center = [0, 0];
end
% Size and origin
s = size(x);
o = floor(s / 2) + 1 + center;
n1 = [1:s(1)] - o(1);
n2 = [1:s(2)] - o(2);
switch lower(type(1))
case 'r'
m1 = (-1) .^ n1;
y = x .* repmat(m1', [1, s(2)]);
case 'c'
m2 = (-1) .^ n2;
y = x .* repmat(m2, [s(1), 1]);
case 'b'
m1 = (-1) .^ n1;
m2 = (-1) .^ n2;
m = m1' * m2;
y = x .* m;
otherwise
error('Invalid input type');
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -