How to plot it please help
2 次查看(过去 30 天)
显示 更早的评论
Hi could you please help me how to write a code which output gives me the below diagram thank you
0 个评论
采纳的回答
Alberto Cuadra Lara
2022-12-22
编辑:Alberto Cuadra Lara
2022-12-22
Hello Melika,
If you want to extract the results, I recommend to use WebPlotDigitizer. This can also be done with MATLAB. Afterwards you can plot it as in the paper, as shown below. If you want to do the simulation this will require more information.
Best,
Alberto
% Load data collected from WebPlotDigitizer
%
% x(:, 1) y(:, 1)
% x(:, 2) y(:, 2)
% x(:, 3) y(:, 3)
% x(:, 4) y(:, 4)
%
% I have collected the data for the first case
[x, y] = load_data();
% Figure settings
config.outerposition = [0.35 0.35 0.6 0.6];
config.linewidth = 2;
config.fontsize = 20;
config.markersize = 12;
config.axis_x = 'tight';
config.axis_y = 'auto';
config.box = 'on';
config.grid = 'on';
config.hold = 'on';
config.labelx = 'Imperfect CSI ($\sigma_{\epsilon}$)';
config.labely = 'Total energy efficiency of V2X network (Mb/J)';
config.legeds = {'AmBC NOMA, $P_{\rm tot}$ = 43 dBm'};
config.legend_location = 'northeast';
% Generate figure
fig = figure;
set(fig, 'units', 'normalized', 'outerposition', config.outerposition);
ax = axes(fig);
% Set settings
set(ax, 'LineWidth', config.linewidth, 'FontSize', config.fontsize - 2)
set(ax, 'BoxStyle', 'full', 'TickLabelInterpreter', 'latex')
set(ax, 'Layer', 'Top');
xlim(ax, config.axis_x);
ylim(ax, config.axis_y);
box(ax, config.box);
grid(ax, config.grid);
hold(ax, config.hold);
xlabel(ax, config.labelx, 'FontSize', config.fontsize, 'interpreter', 'latex');
ylabel(ax, config.labely, 'FontSize', config.fontsize, 'interpreter', 'latex');
% Plot results
plot(ax, x(:, 1), y(:, 1), 'bs-', 'LineWidth', config.linewidth, 'MarkerSize', config.markersize);
% plot(ax, x(:, 2), y(:, 2), 'ks--', 'LineWidth', config.linewidth, 'MarkerSize', config.markersize);
% plot(ax, x(:, 3), y(:, 3), 'bo-', 'LineWidth', config.linewidth, 'MarkerSize', config.markersize);
% plot(ax, x(:, 4), y(:, 4), 'ko--', 'LineWidth', config.linewidth, 'MarkerSize', config.markersize);
% Set legends
legend(ax, config.legeds, 'FontSize', config.fontsize - 2, 'Location', config.legend_location, 'interpreter', 'latex')
% SUB-PASS FUNCTION
function [x, y] = load_data()
% Case 1
x(:, 1) = [0.9916 1.9854 2.9895 3.9937 4.9979 5.9916 6.9958 8.0000 9.0042 10.0084] * 1e-3;
y(:, 1) = [0.0522 0.0369 0.0282 0.0232 0.0186 0.0157 0.0135 0.0119 0.0100 0.0086];
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!