C114门户论坛百科APPEN| 举报 切换到宽版

亚星游戏官网

 找回密码
 注册

只需一步,快速开始

短信验证,便捷登录

搜索
查看: 3859|回复: 0

[原理资料] jakes模型的matlab代码 [复制链接]

军衔等级:

亚星游戏官网-yaxin222  新兵

注册:2012-4-26
发表于 2012-4-26 18:47:20 |显示全部楼层
function  [H] = jakes(Datalen,chanpf,fm,fs,No,startp)
%   Datalen the length of the data
%   chanpf  path numbers
%   fm      max doppla
% startp    used for continuing calculating scenario
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% for debug;
% clear all;
% clc;
% Datalen= 5000;
% chanpf=1;
% fs=1e5;
% fm=50;
%%%%%%%%%%%%%%%
if (~exist('startp')),
   startp = 0;
end
if (~exist('No')),
   startp = 0;
end
if startp == 0;
   flag = 0;
else
   flag = 1;
end
%pathnum = length(chanpf);
pathnum = chanpf;
%Datalen = Datalen + 500;
%clear all
%Datalen = 500000;
%pathnum = 6;
%v = 30 ;                % km/h
%fm = 300;

%Fc = 2e9;             %carrier frequency
%wc = 2*pi*Fc; %radian frequency
%W = 4e6;
Dopplershift=fm;
%fm = 500;
wm  = 2*pi*fm;

%W = 4000*wm;
Ts = 1/fs;              %sampling period
%Ts = 0.002;
% the problem which the amplitued is not Rayleigh distribution caused by the value of Ts.
% wm = 2*pi*fm  when fm = 10  wm = 62.8 T = 0.1. when fm = 100 wm = 628 T = 0.01
% Ts = 1/384e3 = 2.6e-6  10000*Ts = 2.6e-2.(total time).  The number of period is 0.026/0.0159 = 1.6
% the simulation shows when v = 600, fm = 1000, Uder the conditions Ts = 1/384e3 The number of period is 160.
% Then good result can get(rayleigh distribution). So when the v = 6km/h and Ts = 1/384e3, the datalengh should be 1000000
% When Ts = 0.002, 10000*Ts = 20.  20/0.0159 = 1250th period  added July 10
% added at Nov 18 2003
% Ts = 1/(8*wm)  10000*Ts/T = 10000/8 = 1250 periods = 10000*fm/f. More peirods, the
% amplitude dirtribution is more like rayleigh distribution and the phase
% distribution is more like united distribution
t = 0:Ts亚星游戏官网-yaxin222Datalen-1)*Ts; %time array
t = t + startp*Ts;
No = 10;
N = (2*No+1)* 2;

% alpha = pi/4;
alpha = 0;
belta = pi*(1:No)/(No+1);
w = wm * cos(2*pi*(1:No)/N);   
if flag == 1;
    rand('state',0);  % test the rand function will output same sequence because the state is set to the same value
end
phase_init =rand(No,1)*2*pi;% [0 0 0 0 0 0 0 0 ]';%rand(No,1)*2*pi;
for k = 1:No
resin = zeros(No,length(t));
resqu = zeros(No,length(t));
for i = 1:No     
        resin(i,:) = 2*cos(belta(i))*cos(w(i)*t + phase_init(k));
        resqu(i,:) = 2*sin(belta(i))*cos(w(i)*t + phase_init(k));
end
res2in = sum(resin) + sqrt(2) * cos(alpha) * cos(wm*t);
res2qu = sum(resqu) + sqrt(2) * sin(alpha) * cos(wm*t);
y(k,:) = sqrt(1/(2*No+1)).*(res2in + sqrt(-1)* res2qu);
    %y(k,:) = y(k,:)/exp(k-1);  % make it suitable with practice. The power of otherpath is less than the main path.
end
% normalization the channel
for i = 1:No
   y(i,:) = y(i,:)/norm(y(i,:))*sqrt(Datalen);
   %y(i,:) = y(i,:)/sqrt(exp(i-1));
end
H = y(1:pathnum,1:end);
return;
%mean(abs(H(:,:)))
%%%%%%%%%%%%%%%%%%%%%% plot
%for i = 1:10
%    h(:,i) = H(:,(i-1)*50+1);
%end
%figure;
%for i=1:pathnum
    %subplot(pathnum,1,i);
%    plot(abs(H(i,1:20)));%/norm(H(i,:))));
%end
%hold on;
figure;
channel(1,:)=fft([H(1,1:10) zeros(1,118)]);
%power(1,:)=10*log(abs(channel(1,:)));
%plot(power(1,:));
plot(abs(channel(1,:)));
%figure;
%plot(abs(H(1,11:20)));
%figure;
%plot(abs(H(1,1:20)));
%hold on;

举报本楼

您需要登录后才可以回帖 登录 | 注册 |

手机版|C114 ( 沪ICP备12002291号-1 )|联系大家 |网站地图  

GMT+8, 2024-9-25 18:29 , Processed in 0.140286 second(s), 15 queries , Gzip On.

Copyright © 1999-2023 C114 All Rights Reserved

Discuz Licensed

回顶部
XML 地图 | Sitemap 地图