numchans = 2 %信号的州搏信道数
nsamp = 16 %每个符号的采样率
num=10
numerrs = 0% Number of bit errors seen so far
demod_ini_phase = zeros(1,numchans) % 调制相位
mod_ini_phase = zeros(1,numchans) % 解调相位
ini_state = complex(zeros(nsamp,numchans))% 解调状态for i = 1 : num
x = randint(numbits,numchans) %二进制信号
[y,phaseout] = mskmod(x,nsamp,[],mod_ini_phase)
mod_ini_phase = phaseout %用于下次MSK调制使用
[z, phaseout, stateout] =mskdemod(awgn(y,5,'measured'),nsamp,[],demod_ini_phase,ini_state)
ini_state = stateout %用于下次解调使用旁宏
demod_ini_phase = phaseout %用于下次解调使用
%统计误比特率
numerrs = numerrs + length(find(x(:,1)~=z(:,1))) + length(find(x(:,2)~=z(:,2)))
end
ber=numerrs/(numbits*numchans*num)
实现这些功能代码可要编不少, 先把以前编过的给你一段试试看
% MSK数字带通调制仿真n=10000 %总采样点数
count=100
N=n/count %N=100
r=rand(1,N-1) % 产生一个行向量,共9999个
for i=1:N-1,
if (r(i)>=0.5)
r(i)=1
else r(i)=-1
end
end %将这9999个数整数化为 1,-1
for i=1:n-count % 取9900个
R(i)=r(((i-1)-mod((i-1),count))/count+1)
end %
a(1)=1
for i=2:N
if r(i-1)==1
a(i)=-a(i-1)
else a(i)=a(i-1)
end
end
for i=1:n
A(i)=a(((i-1)-mod((i-1),count))/count+1)
end
for i=1:N
郑扒 if(mod(i,2))
l(i)=a(i)
l(i+1)=a(i)
else q(i)=a(i)
q(i-1)=a(i)
end
end
for i=1:n
I(i)=l(((i-1)-mod((i-1),count))/count+1)
end
for i=1:n
Q(i)=q(((i-1)-mod((i-1),count))/count+1)
end
ts=0.0001
Ts=ts*count
fs=1/ts
fc=5/(2*Ts)
t0=Ts*N-ts
f=1/(4*Ts)
df=0.3
tI=[-Ts:ts:t0-Ts]
tQ=[0:ts:t0]
tQ_R=[0:ts:t0-Ts]
c=2*pi*f
u=I.*cos(c*tI)
v=Q.*sin(c*tQ)
U=u.*cos(2*pi*fc*tI)
V=v.*sin(2*pi*fc*tQ)
for i=count+1:n
W(i)=U(i)+V(i-count)
end
figure
subplot(4,1,1)
plot(tQ_R,R,'k')axis([-Ts,0.1,-2,2])
title('数字信号')
grid on
subplot(4,1,2)
plot(tI,A,'k')axis([-Ts,0.1,-2,2])
title('差分编码后的信号')
grid on 羡丛缓
subplot(4,1,3)
plot(tI,I,'k')axis([-Ts,0.1,-2,2])
title('同相调制信号I')
grid on
兄模subplot(4,1,4)
plot(tQ,Q,'k')axis([-Ts,0.1,-2,2])
title('正交调制信号Q')
grid on
figure
subplot(3,1,1)
plot(tI,U,'k')axis([-Ts,0.1,-2,2])
title('Icos(wct)cos(wt)')grid on
subplot(3,1,2)
plot(tQ,V,'k')axis([-Ts,0.1,-2,2])
title('Qsin(wct)sin(wt)')grid on
subplot(3,1,3)
plot(tI,W,'k')axis([-Ts,0.1,-2,2])
title('MSK信号')grid on
没见过你这样定义函数的带源...改下答行悉...function F=w(x,xdata)
--------------------------
把前面那个w.m去了,还有你要新建一个清乎m文件把你的函数存起来...
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)