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

betaTT=90; %
betaRR=90;
Ft_max=570;
Fr_max=570;
alphavT=0;
alphavR=0;
kappa=0;
Ut=45;
tau=0;
Freq_diff=0;
D=300;
Rt=40;
Fc=5.9*10^9;
C=3*10^8;
deltaT=2;
N=20;
% Conversion from degree to radian
betaT=(2*pi*betaTT)/360;
betaR=(2*pi*betaRR)/360;
alpha_0=(2*pi*Ut)/360;
lamda=0.15;
deltaR=linspace(0,2.5,200);
% CF_SB1=zeros(length(deltaT),length(deltaR));
% lambda=(Fc/C);
change_inT=40/300;
alphaT=linspace(-pi,pi,200);
% alphaT=zeros(1,length(alphaT));
for i=1:length(alphaT)
% if (alphaT(i)>-pi)&(alphaT(i)<=pi)
alphaR(i)=pi-(change_inT*sin(alphaT(i)));
end
for b=1:length(deltaR);
% for c=1:length(deltaT);
O=deltaT*cos(alphaT-betaT);
Q=deltaR(b).*cos(alphaR(i)-(betaR));
CF_SB1(b)=(1/(2*pi*besseli(0,kappa)))*trapz(alphaT,exp(sqrt(-1)*2*pi)*(Q+O));
end
figure(1)
plot(deltaR,real(CF_SB1),'--g');
set(0,'DefaultAxesFontSize',18);

16 Comments

Hi Sylvester,
I tried the code on MATLAB R2024a and it executed without any errors. Can you please provide the specific release you are using so I can reproduce the issue? Any additional details related to the issue would be helpful too.
I wanted to replicate results of figure 2 diagram in the paper "An Adaptive Geometry-Based Stochastic Model for Non-Isotropic MIMO Mobile-to-Mobile Channels". Kindly assist if possible.
Thanks in advance for all relevant assistance you are willing to give me regarding the codes.
Which release are you using? The code you provided runs without error in R2024a.
@Walter Roberson, i was trying to replicate the results in the paper https://ncrl.seu.edu.cn/_upload/article/files/6b/e7/f87eaed74373a3cb95970d410dbf/ddf5ed2a-4bcb-4675-a841-b47ba176ec95.pdf and obtain the diagram in figure two, but i could not. Any relevant codes and other information will be welcome sir.
We need to know which MATLAB release you are using, so that we can test the provided code in the same release, to try to recreate the error message about plot.
It is currently irrelevant that you are trying to replicate the results of the paper: we are concentrating on figuring out why you are getting the plot() error.
I am currently using MATLAB R2024a-academic license. Thank you.
I just tested in R2024a (Standard License). The code you posted runs without error, producing a plot that is the same as what is posted in your Question.
Are you sure that the code you posted produces the message "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" ??
I wanted to replicate same diagram in the paper, but could not. At first it produces error with a lower version of MATLAB. My challenge now is how to reproduce same outcome in the academic paper with my codes.
Which version of MATLAB is it producing the error message about Error using plot ?
We are concentrating on the definite ("Error using plot") rather than on the indefinite "reproduce the plot".

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.

@Umar, I am very grateful for taking out time to put me through, i have been having sleepless night. I hope i will have good night rest today. Thank you very much.
Hi @Walter Robertson,
Thank you for your kind words regarding the formatting of my code blocks. I appreciate your feedback and am glad to know that the changes have made a positive impact. You have made a lot of contributions over the past years, helped a lot of OPs resolving their complex problems, appreciate others help such as @DGM, @Torsten, @Cyclist, @Star Strider, @Chris La Pierre, @john D Errico, @dpb etc, all of you have given excellent tips by sharing your knowledge and I am really greatful for it.
Hi @Sylvester,
Thank you for your kind message. I am pleased to hear that our discussion was helpful to you. It is completely understandable to feel overwhelmed at times, and I appreciate your openness in sharing your concerns. I sincerely hope that you are able to enjoy a restful night’s sleep soon. Should you have any further questions or need additional support, please do not hesitate to reach out. Wishing you all the best.

Sign in to comment.

Answers (1)

This question appears to have been resolved, but it still receives a high number of visits.
If you landed on this page looking for "Wireless Channel Modeling", you may want to look here:
That pages gives an overview of various wireless channel models available in Communications Toolbox.
For channels models specific to a given standard (e.g. 5G, LTE, or WLAN), see those toolboxes' respective documentation.

Categories

Find more on Phased Array System Toolbox in Help Center and File Exchange

Asked:

on 18 Jun 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!