声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3514|回复: 2

[其他] Walsh序列如何产生?

[复制链接]
发表于 2007-4-22 17:17 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
matlab函数hadamard(N)可以产生N阶Walsh序列,不过得到的矩阵的行不是按如下图的顺序排列的。

我现在要用到N个点的Walsh序列的前n阶(n<N),所以有没有什么办法能将hadamard函数得到的矩阵按图顺序排列呢?
walshi function of 16 order.png
回复
分享到:

使用道具 举报

 楼主| 发表于 2007-4-23 18:05 | 显示全部楼层
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变换核矩阵的简单生成及其应用》,作者:叶瑞松,廖海泳
 楼主| 发表于 2007-4-23 18:06 | 显示全部楼层
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变换核矩阵的简单生成及其应用》,作者:叶瑞松,廖海泳
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-28 18:45 , Processed in 0.064036 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表