📄 corr.m
字号:
function y = corr(v);% This function calculates the dot product of the vector v with the% 26 shifts of the alphabet frequency vector[vx,vy]=size(v);% If v is the a column vector instead of a row vector, we transpose% to make everything okif (vx==26) & (vy==1), v = v'; endif (~((vx==26) | (vx==1))) | (~((vy==26) | (vy==1))) , error('The vector v needs to be 26x1 or 1x26');endfvec=[.082 .015 .028 .043 .127 .022 .020 .061 .070 .002 ... .008 .040 .024 .067 .075 .019 .001 .060 .063 .091 ... .028 .010 .023 .001 .020 .001];%Loop over all shiftsy=zeros(26,1);for j=0:25, % fsh=[fvec(1+j:26) fvec(1:1+j-1)]; % my way fsh=[fvec(26-j+1:26) fvec(1:26-j)]; % Dr. W's way y(j+1)=v*fsh';end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -