1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
| n_beishu=1; Mx = 4*n_beishu; Mz = 8*n_beishu; fc = 3.5e9; c = 3e8; lambda = c/fc; d = lambda/2;
B = 50e6; N_freq = 1001; frequencies = linspace(fc - B/2, fc + B/2, N_freq);
paths = [ 160e-9, -10, 30, 0; 860e-9, 0, 0, -5 ]; num_paths = size(paths, 1); num_array = Mx*Mz;
paths_power = 10.^(paths(:,4)/10); paths_gain = sqrt(paths_power) ;
x_pos = (-(Mx-1)/2 : (Mx-1)/2) * d; z_pos = (-(Mz-1)/2 : (Mz-1)/2) * d;
[X, Z] = meshgrid(x_pos, z_pos);
X_vec = reshape(X,[],1); Z_vec = reshape(Z,[],1);
theta_range = -90:1:90; phi_range = -90:1:90; N_theta = length(theta_range); N_phi = length(phi_range); spatial_steering_matrix =zeros(num_array,N_theta,N_phi); for theta_idx = 1: N_theta for phi_idx = 1: N_phi kx = sind(phi_range(phi_idx)) * cosd(theta_range(theta_idx)); ky = cosd(phi_range(phi_idx)) * cosd(theta_range(theta_idx)); kz = sind(theta_range(theta_idx)); for array_idx = 1: num_array x_pos_i = X_vec(array_idx); z_pos_i = Z_vec(array_idx); spatial_steering_matrix(array_idx,theta_idx,phi_idx)=exp(-1j*(2*pi/lambda)*[x_pos_i,0,z_pos_i]*[kx;ky;kz ]); end end end
H = zeros(num_array, N_freq);
for p = 1:num_paths delay = paths(p,1); theta = (paths(p,2)); phi = (paths(p,3)); gain = paths_gain(p); [~,search_theta] = min(abs(theta-theta_range)); [~,search_phi] = min(abs(phi-phi_range)); steering_matrix = spatial_steering_matrix(:,search_theta,search_phi); phase_delay = exp(-1j*2*pi*frequencies*delay); H = H + gain * steering_matrix * phase_delay; end
h = ifft(H,N_freq, 2);
delta_t = 1/(frequencies(end)-frequencies(1)); tau = (0:N_freq-1)*delta_t; tau_max = 1000e-9;
valid_idx = tau <= tau_max; tau = tau(valid_idx); h = h(:,valid_idx); N_tau = length(tau);
Power_estimated = zeros(N_theta, N_phi, N_tau);
for t = 1:N_tau for theta_idx = 1: N_theta for phi_idx = 1: N_phi snapshot = h(:,t); steering_vector =spatial_steering_matrix(:,theta_idx,phi_idx); Power_estimated(theta_idx,phi_idx,t) = abs(steering_vector' * snapshot)^2; end end end Power_estimated_dB = 10*log10(abs(Power_estimated));
[theta_mesh, phi_mesh, tau_mesh] = ndgrid(theta_range, phi_range, tau);
figure; scatter3(theta_mesh(:), phi_mesh(:), tau_mesh(:)*1e9, 30, Power_estimated_dB(:), 'filled');
xlabel('Theta (度)'); ylabel('Phi (度)'); zlabel('时延 (ns)'); title('多径信道功率分布 (dB)'); colorbar; colormap('parula'); grid on;
[peak_power, peak_idx] = max(Power_estimated_dB(:)); [theta_idx, phi_idx, tau_idx] = ind2sub(size(Power_estimated_dB), peak_idx); fprintf('主径: Theta=%.2f°, Phi=%.2f°, 时延=%.2f ns, 功率=%.2f dB\n', theta_range(theta_idx), phi_range(phi_idx), tau(tau_idx)*1e9, peak_power);
[~, tau_1_idx] = min(abs(paths(1,1) - tau)); AAP_1 = Power_estimated_dB(:,:,tau_1_idx); AAP_1=AAP_1-max(max(AAP_1)); figure; imagesc(phi_range, theta_range, AAP_1); xlabel('Azimuth Angle \phi (°)'); ylabel('Elevation Angle \theta (°)'); title('Angle-Angle Power at Path 1 Delay [Simulation]'); colorbar; clim([-40 0]); axis xy;
[max_val, max_idx] = max(AAP_1(:)); [theta_idx_max, phi_idx_max] = ind2sub(size(AAP_1), max_idx); theta_peak = theta_range(theta_idx_max); phi_peak = phi_range(phi_idx_max); disp(['主瓣方向为:Elevation = ', num2str(theta_peak), '°, Azimuth = ', num2str(phi_peak), '°']);
hold on; plot(phi_peak, theta_peak, 'ro', 'MarkerSize', 10, 'LineWidth', 2);
text(phi_peak + 5, theta_peak, ['\leftarrow (', num2str(theta_peak), '°, ', num2str(phi_peak), '°)'], 'Color', 'red', 'FontSize', 12, 'FontWeight', 'bold');
|