%multipathmodel.m
%Response to the input signal cos(2*pi*f*t) with f=1
%nop->number of paths
%beta(i)->ith co-efficient in the multipath model.
%delay(i)->delay in the ith path in the multipath model.
%In this experiment, delay is assumed as the variable
%that varies linearly with time and %beta is assumed
%to be the constant for the particular path.
f=1
nop=10;
rxsignal=[];
t=0:1/100:1;
txsignal=cos(2*pi*f*t);
z=1;
for t=0:1/100:1
temp=0;
for p=1:1:nop
beta(p)=rand;
delay(p)=rand*t;
temp=temp+beta(p)*exp(j*2*pi*f*(t-delay(p)));
end
BETACOL{z}=beta;
DELAYCOL{z}=delay;
beta=0;
delay=0;
rxsignal=[rxsignal temp];
z=z+1;
end
save CONSTANTS BETACOL DELAYCOL
figure(1)
subplot(4,1,1)
plot(txsignal)
subplot(4,1,2)
plot(real(rxsignal))
subplot(4,1,3)
plot(abs(fft(txsignal)))
subplot(4,1,4)
plot(abs(fft(real(rxsignal))))
load CONSTANTS
fs=100;
u=1;
for f=0:fs/101:(50*fs)/101
rxsignal=[]
temp=0;
z=1;
for t=0:1/100:1
temp=0;
for p=1:1:nop
temp=temp+BETACOL{z}(p)*exp(j*2*pi*f*(t-DELAYCOL{z}(p)));
end
rxsignal=[rxsignal temp];
z=z+1;
end
%The impulse response of the time-varying channel is computed as follows.
t=0:1/100:1;
timevaryingTF_at_freq_f{u}=rxsignal.*exp(-j*2*pi*f*t);
u=u+1;
end
TEMP=cell2mat(timevaryingTF_at_freq_f');
for i=1:1:101
u=TEMP(:,i);
u1=[u;transpose(u(length(u):-1:2)')];
timevaryingIR_at_time_t{i}=ifft(u1);
end
TFMATRIX=abs(cell2mat(timevaryingTF_at_freq_f'));
IRMATRIX=cell2mat(timevaryingIR_at_time_t)
s=[2:2:8];
for i=1:1:4
figure(2)
subplot(2,2,i)
plot(IRMATRIX(1:1:101,s(i)))
title(strcat('t=',num2str((s(i)-1)/100)))
figure(3)
subplot(2,2,i)
plot(TFMATRIX(:,s(i)))
title(strcat('t=',num2str((s(i)-1)/100)))
end
s=[2:2:20 11:5:100];
for i=1:1:25
figure(4)
subplot(5,5,i)
plot(IRMATRIX(1:1:101,s(i)))
title(strcat('t=',num2str((s(i)-1)/100)))
figure(5)
subplot(5,5,i)
plot(TFMATRIX(:,s(i)))
title(strcat('t=',num2str((s(i)-1)/100)))
end
