clear all, close all % % Change the fDT value below, having run the C-code first, % and some tests will run to demonstrate quality of the fading waveform. % Christos Komninakis, June 2003 % fDT = 0.01; % change this accordingly, to load the appropriate file % a = load(strcat('RayleighCpp/logR', num2str(fDT,'%5.3f'),'.txt')); c = a(:,2) + j*a(:,3); mean(abs(c).^2) mean(c) var(c) %return % C = [c; c; c;]; if (1 > 0) % same thing, either way z = xcorr(C,c); zr = real(z); zi = imag(z); else z1 = xcorr(real(C),real(c)); z2 = xcorr(imag(C),imag(c)); zr = 0.5*(z1 + z2); z3 = xcorr(real(C),imag(c)); z4 = xcorr(imag(C),real(c)); zi = 0.5*(z3 + z4); end; mid = 4*length(c); len = 40/fDT; figure(1) posvec = [0.4 0.4 4.5 3.4]; set(gcf, 'Units', 'inches'); set(gcf, 'Position', posvec); set(gcf, 'PaperPosition', posvec); figure(gcf) clf Jo = besselj(0,2*pi*fDT*[-len:0.1:len]); plot([-len:0.1:len], Jo,'r') hold on; plot([-len:len],zr(mid-len:mid+len)/zr(mid)) plot([-len:len],zi(mid-len:mid+len)/zr(mid),'k') legend('theory','simulation','cross-corr.') hold off grid on % figure(2) posvec = [0.4 0.4 4.5 3.4]; set(gcf, 'Units', 'inches'); set(gcf, 'Position', posvec); set(gcf, 'PaperPosition', posvec); figure(gcf) clf r_s = [-40:4:10]; Nr_s = []; for k=1:length(r_s); r(k) = 10^(r_s(k)/20); d = c/std(c); d = abs(d) - r(k); inds = find((d(1:length(d)-1) < 0) & (d(2:length(d)) > 0)); Nr_s = [Nr_s, [length(inds)/(length(d)-1)]]; end; semilogy(r_s, Nr_s, 'bd'); hold on rr_s = [min(r_s):1:max(r_s)]; r = 10.^(rr_s/20); semilogy(rr_s, sqrt(2*pi)*fDT*r.*exp(-r.^2), 'r-'); hold off; grid on; % break; % % Run this bottom part if you want to plot all the results... % LCR results 0.05 0.01 0.002 %------------------------------------------------------------------- Nr = [ 0.00008250020625 0.00010750026875 0.00005250013125; 0.00025750064375 0.00023250058125 0.00009250023125; 0.00063750159375 0.00050750126875 0.00015500038750; 0.00148500371251 0.00098250245626 0.00021000052500; 0.00370750926877 0.00163750409376 0.00029500073750; 0.00831252078130 0.00267750669377 0.00050500126250; 0.01654754136885 0.00412751031878 0.00073250183125; 0.02779506948767 0.00622251555629 0.00115000287501; 0.04186260465651 0.00879002197505 0.00170250425626; 0.05333763334408 0.01095502738757 0.00216250540626; 0.04610261525654 0.00952502381256 0.00186500466251; 0.01612254030635 0.00332000830002 0.00064750161875; 0.00053500133750 0.00010000025000 0.00002500006250 ]; % figure(3) posvec = [0.4 0.4 4.5 3.4]; set(gcf, 'Units', 'inches'); set(gcf, 'Position', posvec); set(gcf, 'PaperPosition', posvec); figure(gcf) clf semilogy(r_s, Nr(:,1), 'b^'); hold on semilogy(r_s, Nr(:,2), 'bs'); semilogy(r_s, Nr(:,3), 'bo'); rr_s = [min(r_s):1:max(r_s)]; r = 10.^(rr_s/20); semilogy(rr_s, sqrt(2*pi)*0.05*r.*exp(-r.^2), 'r-'); semilogy(rr_s, sqrt(2*pi)*0.01*r.*exp(-r.^2), 'r-'); semilogy(rr_s, sqrt(2*pi)*0.002*r.*exp(-r.^2), 'r-'); hold off; grid on; legend('Simulation005','Simulation001','Simulation0002','theory',3)