Skip to content

Instantly share code, notes, and snippets.

@avgerin0s
Created May 21, 2014 18:41
Show Gist options
  • Save avgerin0s/c3e29810a61f93a7cfd0 to your computer and use it in GitHub Desktop.
Save avgerin0s/c3e29810a61f93a7cfd0 to your computer and use it in GitHub Desktop.
function y = circonvt(x1,x2,N)
% N-������� ������� �������� ������ ��� x1 & x2: (��� ����� ��� ������)
% ---------------------------------------------------------------------
% [y] = circonvt(x1,x2,N)
% y = ��������� ��� �������� ��� ������� ��������
% x1 = ��������� ������� �� ����� N1 <= N
% x2 = ��������� ������� �� ����� N2 <= N
% N = ����� �������� ���������
% �������: y(n) = sum (x1(m)*x2((n-m) mod N))
% ������� ��� �� ����� ��� x1
if length(x1) > N
error('�� N ������ �� ����� >= ��� ������ ��� x1')
end
% ������� ��� �� ����� ��� x2
if length(x2) > N
error('�� N ������ �� ����� >= ��� ������ ��� x2')
end
x1=[x1 zeros(1,N-length(x1))];
x2=[x2 zeros(1,N-length(x2))];
m = [0:1:N-1];
x2 = x2(mod(-m,N)+1);
H = zeros(N,N);
for n = 1:1:N
H(n,:) = CIRSHFTT(x2,n-1,N);
end
y = x1*H';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment