textbox doesnt like strings
Show older comments
%%Aufgabe 3
clear; clc; close all;
A3_ECE = "Daten\Student_2.xls";
A3_ECE_Data = readmatrix(A3_ECE);
[std_ECE,muh_ECE] = std(A3_ECE_Data(:,13));
i=1;
x_ece=A3_ECE_Data(:,2);
y_ece=A3_ECE_Data(:,14);
curve1 = y_ece + std_ECE;
curve2 = y_ece - std_ECE;
nl = newline;
x2 = [x_ece; flipud(x_ece)];
inBetween = [curve1; flipud(curve2)];
x2 = fillmissing(x2, 'linear'); % Fill 'NaN' Values
inBetween = fillmissing(inBetween, 'linear'); % Fill 'NaN' Values
abw = max(A3_ECE_Data(:,14)-A3_ECE_Data(:,13));
% Gesamtzeit für +/- 2km/h berechnen
g_zeit = 0;
d_zeit = 0;
t1 = 0;
for k = 1:1:length(A3_ECE_Data)
vsoll = A3_ECE_Data(k,14);
vroll = A3_ECE_Data(k,13);
t2 = A3_ECE_Data(k,2);
if (vsoll - vroll) > 2 || (vsoll - vroll) < -2
d_zeit = t2 - t1;
g_zeit = g_zeit + d_zeit;
end
t1 = t2;
end
figure(1);
fill(x2,inBetween, 'c', 'EdgeColor', 'c', 'FaceAlpha', 0.1);
hold on;
grid on;
line(x_ece, y_ece,'LineWidth',2);
title('Aufgabe 3: Geschwindigkeitsabweichung');
ylabel('Geschwindigkeit in [km/h]');
xlabel('Zeit in [ms]');
std_label = strcat("Standartabweichung ",num2str(std_ECE,'%.2f')," km/h");
g_zeit = g_zeit/1000;
g_zeit = num2str(g_zeit,'%.2f');
abw = num2str(abw,'%.1f');
info = {"Datei: " A3_ECE "max. Abweichung[km/h]:" abw "Gesamtzeit außerhalb +/- 2km/h [s]:" g_zeit };
inf_label = string(info);
legend(std_label , 'v_{Soll}', 'Location', 'best');
annotation('textbox','String',inf_label,'FitBoxToText','on','VerticalAlignment','top');
Hello, its me again,
so my main problem is that the annatation at the end shows up somewhere in my graph. unfortunatly verticalaligment doesnt work.
secondary problems are that i dont get how strings work. i want
'datei: Daten/student2.xls
max. Abweichung: xxx km/h
Gesamtzeit: xxx s
'
somehow i get a newline after every string. the function newline wasnt working well..
thanks in advance
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
