function [ch_spread_sig h t_delay]=mulit_pathchan(spread_sig,sigmaN)
R=10000; % The length of the bit stream.
t_offset=[0 1 2 3]; %Delay
gain=[0 -10 -15 -20]; %Channel gain in dB
gain_linear=10.^(gain/10);
n = sigmaN*(randn(1,R)+1j*randn(1,R))/sqrt(2);
for ii=1:length(gain_linear)
h(ii,:)=sqrt(gain_linear(ii))*(1/sqrt(2)*(randn(1,R) + 1j*randn(1,R))); % Rayleigh channel
path_out(ii,:)=h(ii,:).*[zeros(1,t_offset(ii)) spread_sig(1:end-t_offset(ii))];
end
ch_spread_sig=sum(path_out,1)+n; % Multipath
t_delay=t_offset;