Walsh序列如何产生?
matlab函数hadamard(N)可以产生N阶Walsh序列,不过得到的矩阵的行不是按如下图的顺序排列的。我现在要用到N个点的Walsh序列的前n阶(n<N),所以有没有什么办法能将hadamard函数得到的矩阵按图顺序排列呢? function X=walshf1(N)
N=ceil(log2(N));
H=hadamard(2^N); %function provided by Matlab to generate Hadamard martrix
Hp=zeros(2^N);
Ep=zeros(2^N);
Wg=zeros(2^N);
Eg=zeros(2^N);
E=eye(2^N);
%matrix with Paley order
for n=1:2^N
p=0;
for i=1:N
p=bitset(p,i,bitget(n-1,N-i+1));
end
Hp(p+1,:)=H(n,:);
Ep(p+1,:)=E(n,:);
end
Hp; % Matrix Hp is the matrix with Paley order
Ep; % the transform matrix for transforming H matrix to Hp matrix
% Matrix with Walsh order
for n=1:2^N
g=0;
% if (bitget(n-1,N)==0)
g=bitset(g,N,bitget(n-1,N));
%else
%g=bitset(g,N,1);
%end
for i=2:N
if (bitget(n-1,N-i+1)==0)
g=bitset(g,N-i+1,bitget(g,N-i+2));
else
g=bitset(g,N-i+1,1-bitget(g,N-i+2));
end
end
Wg(g+1,:)=Hp(n,:);
Eg(g+1,:)=Ep(n,:);
end
Wg; % Matrix Wg is the matrix with Walsh order
Eg; % the transform matrix for transforming Hp matrix to Wg matrix
%matrix with inversed walsh order
for n=1:2^N
m=0;
for i=1:N
m=bitset(m,i,bitget(n-1,N-i+1));
end
Hm(m+1,:)=Wg(n,:);
Em(m+1,:)=Eg(n,:);
end
Hm; % Matrix Hm is the matrix with inversed Walsh order
Em; % the transform matrix for transforming Wg matrix to Hm matrix
X=Wg;
上述函数可以产生N阶walsh序列,转自《walsh变换核矩阵的简单生成及其应用》,作者:叶瑞松,廖海泳 function X=walshf1(N)
N=ceil(log2(N));
H=hadamard(2^N); %function provided by Matlab to generate Hadamard martrix
Hp=zeros(2^N);
Ep=zeros(2^N);
Wg=zeros(2^N);
Eg=zeros(2^N);
E=eye(2^N);
%matrix with Paley order
for n=1:2^N
p=0;
for i=1:N
p=bitset(p,i,bitget(n-1,N-i+1));
end
Hp(p+1,:)=H(n,:);
Ep(p+1,:)=E(n,:);
end
Hp; % Matrix Hp is the matrix with Paley order
Ep; % the transform matrix for transforming H matrix to Hp matrix
% Matrix with Walsh order
for n=1:2^N
g=0;
% if (bitget(n-1,N)==0)
g=bitset(g,N,bitget(n-1,N));
%else
%g=bitset(g,N,1);
%end
for i=2:N
if (bitget(n-1,N-i+1)==0)
g=bitset(g,N-i+1,bitget(g,N-i+2));
else
g=bitset(g,N-i+1,1-bitget(g,N-i+2));
end
end
Wg(g+1,:)=Hp(n,:);
Eg(g+1,:)=Ep(n,:);
end
Wg; % Matrix Wg is the matrix with Walsh order
Eg; % the transform matrix for transforming Hp matrix to Wg matrix
%matrix with inversed walsh order
for n=1:2^N
m=0;
for i=1:N
m=bitset(m,i,bitget(n-1,N-i+1));
end
Hm(m+1,:)=Wg(n,:);
Em(m+1,:)=Eg(n,:);
end
Hm; % Matrix Hm is the matrix with inversed Walsh order
Em; % the transform matrix for transforming Wg matrix to Hm matrix
X=Wg;
终于解决了,上述函数可以产生N阶walsh序列,转自《walsh变换核矩阵的简单生成及其应用》,作者:叶瑞松,廖海泳
页:
[1]