thesis/plot_error.m

24 lines
743 B
Matlab
Raw Normal View History

function plot_error(t,ref,x)
2024-08-31 13:31:17 +02:00
hold on
ex = ref(:, 1) - x(:, 1);
ey = ref(:, 2) - x(:, 2);
error_norm = sqrt(ex.*ex + ey.*ey);
2024-09-06 15:49:32 +02:00
plot(t, error_norm, 'Linewidth', 5, 'DisplayName', 'norm of error [m]');
2024-08-31 13:31:17 +02:00
avg = ones(1, length(error_norm)) * error_norm / length(error_norm);
2024-09-06 15:49:32 +02:00
plot(t, avg*ones(1, length(error_norm)), 'DisplayName', 'average error [m]', 'LineWidth', 3);
Axes = gca;
Axes.FontSize=18;
Axes.FontWeight='bold';
Axes.PlotBoxAspectRatio = [1 1 1];
grid minor;
2024-08-31 13:31:17 +02:00
legend('FontSize', 12, 'Location', 'northeast', 'AutoUpdate','off')
xlabel("\textbf{t [s]}", FontSize=18, Interpreter="latex")
2024-09-06 15:49:32 +02:00
ylabel("\textbf{tracking error}", FontSize=18, Interpreter="latex")
2024-08-31 13:31:17 +02:00
hold off
end