You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
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 Comments
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.
Answers (0)
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)