PDS/homework_2/matlab/plotsA.m

47 lines
1.2 KiB
Matlab

% Data from the table
Q = [20, 23, 25, 27];
p_values = [1, 2, 3, 4, 5, 6, 7];
measurements = [
40, 42, 62.87, 123.25, 158.81, 233.52, 325.23 ; % Q=20
285, 331.7, 465.5, 956.7, 1364.5, 1755.5, 2108.1 ; % Q=23
1174, 1354.5, 1940.4, 3994.2, 5373.8, 7139.9, 8353.4 ; % Q=25
4761.5, 5952.5, 8154.7, 15910, 21440, 27800, 33298 ; % Q=27
];
% ToDo: Add the measurements
% Create the figure window
figure('Name', 'Results', 'Position', [100, 100, 1600, 720]);
% Plot 1: One plot for each Q
subplot(1, 2, 1);
hold on;
for i = 1:length(Q)
plot(1:length(p_values), measurements(i, :), '-o', 'DisplayName', sprintf('Q=%d', Q(i)));
end
hold off;
xlabel('p');
ylabel('Time (ms)');
title('Plot for each Q');
legend('Location', 'northwest');
grid on;
xticks(1:length(p_values));
xticklabels(1:length(p_values));
% Plot 2: One line for each p
subplot(1, 2, 2);
hold on;
for j = 1:length(p_values)
plot(Q, measurements(:, j), '-o', 'DisplayName', sprintf('p=%d', j));
end
hold off;
xlabel('Q');
ylabel('Time (ms)');
title('Plot for each p');
legend('Location', 'northwest');
grid on;
% Enhance appearance
% sgtitle('Measurement Results');
print(gcf, 'AllMeasurements', '-dpng', '-r300');