The Matlab code shown below was created to plot the amplitude of h0 versus time (sampling the time interval every 1ms, starting from time 0s to time 1s) in reference to the RX that is moving at 72km/h away from the TX, along the horizontal line winding up 20m further away from the TX using the discrete baseband channel model h0 equation. I am supposed to plot the cumulative distribution function (CDF) of the squared amplitude and phase of h0, shown in the Matlab code below, from the samples collected,1001 samples in total (two distinct figures) and compare the resulting CDFs with the Rayleigh fading case. I had to tweak my original code but when I tried to run it in Matlab, I get an error in line 41 that states the following message:
Unable to perform assignment because the left and right sides have a different number of elements.
Error in cdf_rayleigh_comparison (line 41)
h0_squared_abs_samples(i) = abs(h0).^2;
I am uncertain on how to resolve this. I think the issue is that the index i is linked to 10000 samples and (h0) is linked to the time vector t_new = linspace(0,1,1001); unless this is a wrong assumption. Can someone here please see how I may resolve this issue for I am not really Matlab savvy. There may be another error past line 41 which I cannot see yet. Also, if the original problem statement called for 1001 samples, should not the number of samples variable num_samples = 10000; be 1001 as well? The problem statement, along with the physical model of the distance between the transmitter and receiver are shown below. The discrete baseband channel model complex channel filter tap at time m equation is also shown below. Thank you in advance.
t_new = linspace(0,1,1001);
tau = [0.2387 4E-6 3.40E-6 3.667E-6 3.59E-6];
h0_squared_abs_samples = zeros(1, num_samples);
h0_phase_samples = zeros(1, num_samples);
h0 = zeros(1,length(t_new));
dist = v * rand() * max(t_new);
a = randn(1, length(tau_rand)) + 1j*randn(1, length(tau_rand));
h0(m) = sum(a.*sinc(-t_new(m)*tau_rand*W));
h0_squared_abs_samples(i) = abs(h0).^2;
h0_phase_samples(i) = angle(h0);
end
Unable to perform assignment because the left and right sides have a different number of elements.
[f, x] = ecdf(h0_squared_abs_samples);
[f, x] = ecdf(h0_phase_samples);
title('CDF of Phase(h_0)');