diff options
| -rw-r--r-- | Kod/bilbana/Graph/graphs.m | 14 | ||||
| -rw-r--r-- | Kod/bilbana/Graph/graphs_test.m | 11 | ||||
| -rw-r--r-- | Kod/bilbana/Graph/lap_time_graph.m | 52 | ||||
| -rw-r--r-- | Kod/bilbana/Graph/segment_time_graph.m | 15 |
4 files changed, 92 insertions, 0 deletions
diff --git a/Kod/bilbana/Graph/graphs.m b/Kod/bilbana/Graph/graphs.m new file mode 100644 index 0000000..42a1196 --- /dev/null +++ b/Kod/bilbana/Graph/graphs.m @@ -0,0 +1,14 @@ +function [] = graphs(lap_times,ref_lap_time, seg_times, track) +%{GRAPHS: Två grafer i samma figur. Varvtider och medeltid/segment +%{ +lap_times: vektor med alla varvtider, +ref_lap_time: Den varvtid som eftersträvas +seg_times: matris med segmentstider från alla varv +track: den bana som de andra argumenten gäller för +%} +figure(track); +clf; +lap_time_graph(lap_times,track,ref_lap_time); +segment_time_graph(seg_times,track); +end + diff --git a/Kod/bilbana/Graph/graphs_test.m b/Kod/bilbana/Graph/graphs_test.m new file mode 100644 index 0000000..3a2a2e5 --- /dev/null +++ b/Kod/bilbana/Graph/graphs_test.m @@ -0,0 +1,11 @@ +%% Data needed +car1.seg_times = [3.9,1.1,2.2,1.8,1.4,3.9,1.5,3.4,1.4; + 4.2,1.1,2.2,1.8,1.4,3.4,1.5,3.4,1.4; + 3.2,1.1,2.2,1.8,1.4,3.2,1.5,3.4,1.4; + 4.0,1.4,2.2,1.8,1.4,3.4,1.5,3.4,1.4; + 4.0,1.1,2.2,1.8,1.4,3.6,1.5,3.4,1.4; + 4.1,1.1,2.2,1.8,1.4,3.8,1.5,3.4,1.4]; +car1.lap_times = [14.1,13.8,14.15,13.9,14.1,14]; +ref_lap_time = 14; +%% Actual test +graphs(car1.lap_times,ref_lap_time,car1.seg_times,1)
\ No newline at end of file diff --git a/Kod/bilbana/Graph/lap_time_graph.m b/Kod/bilbana/Graph/lap_time_graph.m new file mode 100644 index 0000000..8d54c6a --- /dev/null +++ b/Kod/bilbana/Graph/lap_time_graph.m @@ -0,0 +1,52 @@ +function [outputArg1,outputArg2] = lap_time_graph(lap_times, track, ref_lap_time) +%LAP_TIME_GRAPH En graf som visar varvtider där referenstiden och maximalt +%tillåtna avvikelser är utmärkta. Figuren inkluderar också standardavvikelsen +%% +subplot(20,1,1:8); +%% Raka streck +ref_lap_time_vector = ref_lap_time*ones(1,length(lap_times)); + +Min_c = ref_lap_time-0.5; +Max_c = ref_lap_time+0.5; +InD_c = ref_lap_time-1; +InU_c = ref_lap_time+1; + +Min = Min_c*ones(1,length(lap_times)); +Max = Max_c*ones(1,length(lap_times)); +InU = InU_c*ones(1,length(lap_times)); +InD = InD_c*ones(1,length(lap_times)); +%% Varvtider +plot1 = stairs(lap_times); +plot1.Marker = 'o'; +plot1.MarkerFaceColor = 'k'; +plot1.LineStyle = 'none'; +hold on +%% Referenstid +plot2 = stairs(ref_lap_time_vector); +plot2.LineWidth = 2; +plot2.Color = 'k'; +%% Tillåten avvikelse +plotMax = stairs(Max); +plotMin = stairs(Min); +plotMax.Color = 'k'; +plotMin.Color = 'k'; +%% Osynliga hjälpstreck +plotInU = stairs(InU); +plotInD = stairs(InD); +plotInU.LineStyle = 'none'; +plotInD.LineStyle = 'none'; + +hold off +%% Standardavvkielse +sigma = std(lap_times); +sigma = round(sigma, 2); +sig_str = string(sigma); +%% Text +xlabel('Varv'); +ylabel('Tid [s]'); +Tit = join(['Varvtider bana',string(track)]); +title(Tit); +txt = join(['Standardavvikelse:',sig_str, 's/varv']); +annotation('textbox',[.1 0.5 .5 .05],'String',txt,'EdgeColor','none') +end + diff --git a/Kod/bilbana/Graph/segment_time_graph.m b/Kod/bilbana/Graph/segment_time_graph.m new file mode 100644 index 0000000..f88c836 --- /dev/null +++ b/Kod/bilbana/Graph/segment_time_graph.m @@ -0,0 +1,15 @@ +function [] = segment_time_graph(seg_time,track) +%SEGMENT_TIME_GRAPH Snittid för varje segment. + +avr_seg_time = mean(seg_time); +subplot(20,1,13:20); + +Plot = bar(avr_seg_time); +%Plot.Marker = 'o'; +Plot.FaceColor = 'k'; +xlabel('Segment'); +ylabel('Tid [s]'); +Tit = join(['Medeltid/segment bana',string(track)]); +title(Tit); +end + |
