45 lines
1.3 KiB
Matlab
45 lines
1.3 KiB
Matlab
clear; clc; close all;
|
|
|
|
fig_config();
|
|
|
|
%% Initiate test plot data
|
|
x = linspace(0, 10, 14);
|
|
|
|
% -- bounds
|
|
upper_bound = ones(size(x)) * 4.5;
|
|
lower_bound = upper_bound * 0.4
|
|
|
|
% -- lines
|
|
method_1_1 = upper_bound - (upper_bound - lower_bound) .* exp(-0.7 * x);
|
|
method_1_2 = upper_bound - (upper_bound - lower_bound) .* exp(-0.5 * x);
|
|
method_1_3 = upper_bound - (upper_bound - lower_bound) .* exp(-0.3 * x);
|
|
method_2 = upper_bound - (upper_bound - lower_bound) .* exp(-0.5 * x) .* cos(x);
|
|
|
|
|
|
%% Plot
|
|
x_min = 0; x_max = 10;
|
|
y_min = 2; y_max = 6;
|
|
fig = figure(); hold on; box on; grid on;
|
|
line_optimal = plot(x, upper_bound, 'k-', 'DisplayName', 'Optimal');
|
|
line_method_1 = plot(x, method_1_1, '^b-', 'DisplayName', 'Method 1');
|
|
plot(x, method_1_2, '^b--')
|
|
plot(x, method_1_3, '^b-.')
|
|
line_method_2 = plot(x, method_2, '*r-', 'DisplayName', 'Method 2');
|
|
xlim([x_min, x_max]);
|
|
ylim([y_min, y_max]);
|
|
xticks(x_min:1:x_max);
|
|
yticks(y_min:1:y_max);
|
|
|
|
% -- Add arrow
|
|
arrow([2.5, 4.2], [3.8, 3]);
|
|
text(4, 3, '$\gamma = 1, 2, 3$')
|
|
|
|
% -- Add legends and labels
|
|
% h = findobj(fig, '-regexp', 'DisplayName', '.+');
|
|
lgd = legend([line_optimal, line_method_1, line_method_2]);
|
|
set(lgd, 'ItemTokenSize', [10, 5]);
|
|
ylabel("$\mathbf{E}\left[S\right]$")
|
|
xlabel("Rounds of Iteration")
|
|
|
|
% -- export
|
|
fig_export('example_matlab.pdf', 'pdf', '../../images') |