求高手指导 怎么用matlab求m序列的自相关函数 怎么用VHDL代码在quartus里面仿真 求具体操作步骤 感激不尽!

2024-11-29 01:54:55
推荐回答(1个)
回答1:

function [p m] = correlation_f(x, y)
if nargin == 0
t = 0.01:0.01:2*pi;
x = sin(t);
y = sin(t+pi/2);
end
if nargin == 1
y = x;
end

nlength = length(x);
m = fix(nlength/4);

% initialized data
p(2*m+1) = 0;

for i = -m:m;
if i <= 0
n_x = -i+1:nlength;
n_y = 1:nlength+i;
else
n_x = 1:nlength-i;
n_y = i+1:nlength;
end
pdenominator = sqrt(sum(x(n_x).^2)*sum(y(n_y).^2));
p(i+m+1) = sum(x(n_x).*y(n_y))/pdenominator;
end

% plot(-m:m,p)
恰好有自相关函数的求取代码,另一个问题就不知道了。