How can I only put all the coverage area and FECs in one figure?
1 次查看(过去 30 天)
显示 更早的评论
I am trying to put all the coverage area with blue color that is shown below in one figure to see the overlapping area:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1408764/image.png)
At the same time, in another figure, I would like to plot only the FEC, which is equal to 3.8e-3 and shown with white color in the above figure.
The FEC is a threshold, and the area under this threshold is our target.
I was able to plot them all, but in different figures; what I am interested in is plotting only the blue coverage area for the seven cases in one figure and the FEC for cases in one figure.
Something like the illustration, below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1408769/image.jpeg)
Is it possible? Any assistance, please?
Below is the Matlab mat file
This is my code:
% Create a 2-by-4 layout
tiledlayout(2,4)
% Plot into each tile
for i = 1:7
% Get the next tile
nexttile
A = berMap(i,1);
% caculate the coverage area
isSmaller = cellfun( @(X) X < 3.8e-3, A(:), 'UniformOutput', false);
numSmaller = sum(sum(isSmaller{:} == 1));
% Draw BerMap
Coverage_area = (numSmaller/(41*41))*400; %Important
surf(X_r,Y_r,A{1,1})
colorbar
view(0,90)
xlabel('X (m)');
ylabel('Y (m)');
zlabel('BER');
axis([-L/2 L/2 -W/2 W/2 min(min(A{1,1})) max(max(A{1,1}))]);
grid on;
hold on;
% Plotting the FEC
Amat = cell2mat(berMap(i,1));
Amat(Amat > 3.8e-3) = 0;
Amatrix = Amat;
Amatrix(Amat == 0) = nan;
hSurface = surf(X_r,Y_r,Amatrix);
set(hSurface, 'EdgeColor',[1 1 1],'FaceColor',[1 1 1]);
view(0,90)
end
1 个评论
Varun
2023-8-28
Hello! The google drive above does not work! Can you please attach the MAT file to this question by using the paper-clip icon?
回答(1 个)
Shubham
2023-8-29
Hello Haitham AL Satai,
Since the plotting of coverage area and FEC can be done independently, it is possible to make two separate plots as you desire.
You can create one figure and axes and plot all coverage area within this plot using a single for loop. Similarly, you can repeat this task for the FEC.
Pseudocode for the same could look like:
% Create a figure and axes
figure;
axes;
% Plot the coverage area
for i = 1:7
plotCoverageArea(i);
hold on;
end
% Add legends and title
xlabel('X (m)');
ylabel('Y (m)');
In the above code “plotCoverageArea(i)” plots the coverage area in the ith iteration.
Repeat the steps in above pseudocode for FEC as well. Hope this works!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!