Wireless channel modeling: Error using plot Specify the coordinates as vectors or matrices of the same size, or as a vector and a matrix that share the same length in at least
16 个评论
Hi @Sylvester,
I executed code posted by you in the form above and it executed without errors. Please see attached.
After thoroughly going through attached pdf, I was able to implement code since you mentioned relevant to pertinent information provided in research document. Although it was not easy task and normally we try to focus on resolving problems posted in mathworks form posted by OPs. This type of work normally should be posted for freelance software programmers to help out with these kind of problems. However, if you are stuck with a problem in MATLAB, facing difficulties to resolve or need guidance then feel free to ask us for help and assistance, we will be more happy to help out.
So, going back to your request, I created a test script which is designed to calculate and visualize the Space Correlation Functions (CFs) and Doppler Power Spectral Densities (PSDs) for different scenarios in a communication system. First, I define constants.
f = 5.9e9; % Frequency in Hz
f_c_T_max = 570; % Maximum Doppler frequency in Hz
D = 300; % Distance between Tx and Rx in meters
a = 200; % Antenna spacing in meters
R = 40; % Radius in meters
Then, I defined two scenarios for testing: Scenario a representing isotropic environments with specific angles while Scenario b defines non-isotropic environments with different angles.
k_TR_a = 0; % Scenario a: isotropic environments
k_TR_b = 3; % Scenario b: non-isotropic environments
mu_TR_a = 0; % Scenario a: same direction
mu_TR_b = pi/4; % Scenario b: angle for TR
mu_EL_a = 3*pi/4; % Scenario a: angle for EL
mu_EL_b = 3*pi/4; % Scenario b: angle for EL
Then, I defined space correlation function (This function calculates the Space Correlation Function (CF) based on the model parameters. It uses the exponential decay model influenced by the parameters k, mu, R, and D) and Doppler power spectral density functions (This function computes the normalized Doppler PSD using the provided frequency and distance parameters).
function CF = calculateSpaceCFs(k, mu, R, D)
CF = exp(-k * (D/R) * (1 - cos(mu)));
end
function PSD = calculateDopplerPSD(f, f_c_T_max, D, a)
PSD = (f_c_T_max / (f * D)) * exp(-f_c_T_max / (f * a));
end
Then, I calculates the Space CFs for both scenarios (single-bounce and double-bounce) using the defined functions and used assertions to make sure that the calculated CF values are within valid bounds (0 to 1).
CF_SB_a = calculateSpaceCFs(k_TR_a, mu_TR_a, R, D);
CF_DB_a = calculateSpaceCFs(k_TR_a, mu_EL_a, R, D);
CF_SB_b = calculateSpaceCFs(k_TR_b, mu_TR_b, R, D);
CF_DB_b = calculateSpaceCFs(k_TR_b, mu_EL_b, R, D);
assert(CF_SB_a >= 0 && CF_SB_a <= 1, 'CF_SB_a is out of bounds');
assert(CF_DB_a >= 0 && CF_DB_a <= 1, 'CF_DB_a is out of bounds');
assert(CF_SB_b >= 0 && CF_SB_b <= 1, 'CF_SB_b is out of bounds');
assert(CF_DB_b >= 0 && CF_DB_b <= 1, 'CF_DB_b is out of bounds');
Afterwards, performed calculation for Doppler PSDs for both scenarios mentioned above and used assertions for PSDs as well which is similar to CFs.
PSD_a = calculateDopplerPSD(f, f_c_T_max, D, a);
PSD_b = calculateDopplerPSD(f, f_c_T_max, D, a);
assert(PSD_a >= 0, 'PSD_a is negative');
assert(PSD_b >= 0, 'PSD_b is negative');
Finally, the results for Space CFs and Doppler PSDs are printed to the command window for review along with
fprintf('Space CFs for Scenario a: Single-Bounce = %.4f, Double-Bounce =
%.4f\n', CF_SB_a, CF_DB_a);
fprintf('Space CFs for Scenario b: Single-Bounce = %.4f, Double-Bounce =
%.4f\n', CF_SB_b, CF_DB_b);
fprintf('Doppler PSDs: Scenario a = %.4f, Scenario b = %.4f\n', PSD_a, PSD_b);
The results for Space CFs and Doppler PSDs are printed to the command window for review along with plots generated for Space CFs for both scenarios and Doppler PSDs for both scenarios, allowing for a comparative analysis of the spectral densities.
figure;
hold on;
x_space = linspace(0, D, 100);
y_SB_a = calculateSpaceCFs(k_TR_a, mu_TR_a, R, x_space);
y_DB_a = calculateSpaceCFs(k_TR_a, mu_EL_a, R, x_space);
y_SB_b = calculateSpaceCFs(k_TR_b, mu_TR_b, R, x_space);
y_DB_b = calculateSpaceCFs(k_TR_b, mu_EL_b, R, x_space);
plot(x_space, y_SB_a, 'b', 'DisplayName', 'Single-Bounce Scenario a');
plot(x_space, y_DB_a, 'r', 'DisplayName', 'Double-Bounce Scenario a');
plot(x_space, y_SB_b, 'g', 'DisplayName', 'Single-Bounce Scenario b');
plot(x_space, y_DB_b, 'm', 'DisplayName', 'Double-Bounce Scenario b');
xlabel('Distance (m)');
ylabel('Space Correlation Function');
title('Space CFs for Different Scenarios');
legend show;
grid on;
hold off;
figure;
hold on;
x_doppler = linspace(0, f_c_T_max, 100);
y_PSD_a = calculateDopplerPSD(f, f_c_T_max, D, a);
y_PSD_b = calculateDopplerPSD(f, f_c_T_max, D, a);
plot(x_doppler, y_PSD_a * ones(size(x_doppler)), 'b', 'DisplayName', 'Doppler
PSD Scenario a');
plot(x_doppler, y_PSD_b * ones(size(x_doppler)), 'r', 'DisplayName', 'Doppler
PSD Scenario b');
xlabel('Frequency (Hz)');
ylabel('Normalized Doppler PSD');
title('Normalized Doppler PSDs for Different Scenarios');
legend show;
grid on;
hold off;
Please see attached plots.
Hope, this helps.
回答(0 个)
另请参阅
类别
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)