⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ai_raych.mht

📁 Channel Raylay, help me code matlab
💻 MHT
字号:
From: <Saved by Microsoft Internet Explorer 5>
Subject: 
Date: Mon, 16 Feb 2009 22:22:47 +0700
MIME-Version: 1.0
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.mathworks.com/matlabcentral/files/9158/ai_RayCh.m
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2900.2180" name=3DGENERATOR></HEAD>
<BODY><PRE>%=20
%
% Rayleigh Fading Channel Signal Generator=20
% Using the Dent Model (a modification to the Jakes Model)
%
% Last Modified 10/18/05
%
% Author: Avetis Ioannisyan (avetis@60ateight.com)
%
%
% Usage:
% [omega_mTau, Tk] =3D=20
% ai_RayCh(NumAngles, Length, SymbolRate, NumWaveforms, CarrierFreq, =
Velocity)
%
% Where the output omega_mTau is a time scaling factor for plotting
% normalized correlations. The LAGS value output by [C,LAGS] =3D =
XCORR(...)
% should be multiplied by the omega_mTau scaling factor to properly =
display
% axis. Tk is a two dimensional vector [M, N] =3D SIZE(Tk) with
% M=3DnumWaverorms and N=3DLength specified in the RayCh(...) function =
call
%
% And the input variables are:
%
% NumAngles - scalar power of 2, NumAngles &gt; 2^7 is used to specify =
the
% number of equally strong rays arriving at the receiver. It used to
% compute the number of oscillators in the Dent model with N0 =3D =
numAngles/4
%
% Length - scalar preferably power of 2 for faster computation, Length =
&gt; 2^17
% is used to specify the length of the generated sequence. Lengths near =
1E6
% are close to realistic signals
%=20
% SymbolRate - scalar power of 2 and is in kilo-symbols-per-sec is used =
to
% specify what should be the transmission data rate. Slower rates will
% provide slowly fading channels. Normal voice and soem data rates are
% 64-256 ksps
%
% NumWaveforms - scalar used to specify how many 'k' waveforms to =
generate
% in the model. NumWaveforms &gt; 2 to properly display plots
%=20
% CarrierFreq - scalar expressed in MHz is the carrier frequency of the
% tranmitter. Normally 800 or 1900 MHz for mobile comms
%
% Velocity - scalar expressed in km/hr is the speed of the receiver.=20
% 100 km/hr =3D 65 mi/hr. Normal values are 20-130 km/hr
%=20
% Usage Examples:
% [omega_mTau, Tk] =3D ai_RayCh(2^7, 2^18, 64, 2, 900, 100)
%=20
% where
%
% NumAngles=3D2^7, Length=3D2^18, symbolRate=3D64, NumWaveforms=3D2, =
carrierFreq=3D900, Velocity=3D100
% [omega_mTau, Tk] =3D RayCh(NumAngles, Length, symbolRate, =
NumWaveforms,
% carrierFreq, Velocity);
%
%


function [omega_mTau, Tk] =3D ai_RayCh(NumAngles, Length, symbolRate, =
NumWaveforms, carrierFreq, Velocity)

% Number of oscillators
N0 =3D NumAngles/4;
% Maximum Doppler shift of carrier at some wavelength
omega_m =3D (2*pi) * fm(Velocity, carrierFreq);
% specify variance of the Rayleigh channel
% use this for *constant* variange - requires changing other params in =
prog
sigma2 =3D 10;
% make sigma2 a gaussian RV around u =3D sigma2 and var =3D sigma2/5
% use for *non constant* variaance - requires changing other params in =
prog
sigma2 =3D sigma2 + sqrt(sigma2/5) .* randn(1,NumWaveforms);
% Initialize phases
alpha_n =3D []; beta_n =3D []; theta_nk =3D [];=20
% make a hadamard matrix
Ak =3D hadamard(N0);
% determine phase values 'alpha' and 'beta'
n=3D[1:N0];
alpha_n =3D 2*pi*n/NumAngles - pi/NumAngles;
beta_n =3D pi*n/N0;

% convert to time scale using 'fs' sampling frequency
t=3D[1/(symbolRate*1000):1/(symbolRate*1000):1/(symbolRate*1000) * =
Length];

Tk =3D [];
for q =3D 1 : NumWaveforms

    rand('state',sum(100*clock))                % reset randomizer
    theta_nk =3D rand(1,length(n)) * 2 *pi;       % create uniform =
random phase in range [0,2pi]

    sumRes =3D 0;
	for i =3D 1 : N0
        term1 =3D Ak(NumWaveforms,i);
        term2 =3D cos(beta_n(i)) + j*sin(beta_n(i));
        term3 =3D cos(omega_m .* t .* cos(alpha_n(i)) + theta_nk(i));
        sumRes =3D sumRes + (term1 .* term2 .* term3);
	end
   =20
    Tk(q,:) =3D sqrt(2/N0) .* sumRes;
    % use line below to apply *non-constant* variance=20
    Tk(q,:) =3D repmat(10.^(sigma2(q)/20),1, Length) .* Tk(q,:); %apply =
variable in dB=20

end

% apply *constant* variance unilaterly in dB=20
% Tk =3D repmat(10^(sigma2/20), k, Length) .* Tk;=20


% plot results
figure(20); subplot(3,1,1); semilogy(t,abs(Tk(1,:)));
xlabel('Time (sec)'); ylabel('Signal Strength (dB)');=20
title(['Received Envelope, Symbol Rate =3D ', num2str(symbolRate), =
',Carrier =3D ', num2str(carrierFreq), ', Velocity =3D ', =
num2str(Velocity)]);
% compute auto and cross correlations and plot them
omega_mTau =3D (1/(symbolRate*1000)) * (omega_m/(2*pi));    % compute =
omega_m * tau scaling
[C1, Lags] =3D crosscorr(Tk(1,:), Tk(2,:), 20000);
[C2, Lags2] =3D autocorr(Tk(1,:),  20000);
figure(20); subplot(3,1,3); plot(Lags * omega_mTau, C1);
xlabel('Normalized Time Delay'); ylabel('Normalized Crosscorrelation');=20
title('Crosscorrelation between waveforms k=3D1 and k=3D2');
figure(20); subplot(3,1,2); plot(Lags2 * omega_mTau, C2);
xlabel('Normalized Time Delay'); ylabel('Normalized Autocorrelation');=20
title('Autocorrelation of the first waveform k=3D1');




</PRE></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -