corre.m

来自「一个实现循环卷积、因式分解的参考程序」· M 代码 · 共 30 行

M
30
字号
function [r,lag]=corre(x,string,id,y)
% x:the reference sequence
% y:the second sequence
% Compute the correlation sequence
if nargin<3
    error('Not enough input varibles')
end
if nargin==3
    y=x;
    n1=length(y)-1;
    n2=n1;
else
    n1=length(y)-1;
    n2=length(x)-1;
end
r = conv(x,fliplr(y));
lag= (-n1):n2;
%画图
figure(ceil(id/4)+2)
id=rem(id,4);
if id==0
    id=4;
end
subplot(220+id)
stem(lag,r);
xlabel('Lag index'); ylabel('Amplitude');
title(string)
v = axis;
axis([-n1 n2 v(3:end)]);

⌨️ 快捷键说明

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