From c165b264218e1320d7ba1f74976aa2448a6b5b29 Mon Sep 17 00:00:00 2001 From: Albin Date: Wed, 23 Oct 2019 16:21:52 +0200 Subject: fix #4 och fix #2 --- Kod/bilbana/Graph/graphs_test.m | 17 +++++++++------- Kod/bilbana/Graph/segment_time_graph.m | 37 ++++++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/Kod/bilbana/Graph/graphs_test.m b/Kod/bilbana/Graph/graphs_test.m index 3a2a2e5..451bbf1 100644 --- a/Kod/bilbana/Graph/graphs_test.m +++ b/Kod/bilbana/Graph/graphs_test.m @@ -1,11 +1,14 @@ %% 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]; +A = [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.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, 0, 0, 0]; +B = [3.9,1.1,2.2,1.8,1.4,3.9, 0, 0, 0]; +C = [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, 0, 0, 0]; +car1.seg_times = C; 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 +graphs(car1.lap_times,ref_lap_time,car1.seg_times,7) \ No newline at end of file diff --git a/Kod/bilbana/Graph/segment_time_graph.m b/Kod/bilbana/Graph/segment_time_graph.m index 602938b..5ae0690 100644 --- a/Kod/bilbana/Graph/segment_time_graph.m +++ b/Kod/bilbana/Graph/segment_time_graph.m @@ -1,11 +1,36 @@ -function [] = segment_time_graph(seg_time, track) -%SEGMENT_TIME_GRAPH Snittid för varje segment. -seg_time_size = size(seg_time); -avr_seg_time = mean(seg_time(1:(seg_time_size(1) - 1), 1:(seg_time_size(2)))); -subplot(20, 1, 13:20); +function [] = segment_time_graph(seg_times, track) +%SEGMENT_TIME_GRAPH Stapeldiagram med snittid för varje segment. + %{ + Utgår ifrån en r*k matris (seg_times). I den finns segmenttider lagrade + enligt rad ~ varv och kollonn ~ segment. Funktionen summerar alla + kollonner och delar summan med antalet kolloner som inte har värdet 0. + Sedan ritas ett stapeldiagram där varje stapel motsvarar en kollon i + den nyligen beräknade 1*k matrisen. + %} +seg_time_size = size(seg_times); +divide_by_n = ones(1,seg_time_size(2)); +%% Summera seg_time om seg_time ~= 0 +for r = 1:seg_time_size(1) + if r == 1 + avr_seg_time(1:seg_time_size(2)) = seg_times(1:seg_time_size(2)); + else + for c = 1:seg_time_size(2) + x = seg_times(r,c); + if x ~= 0 + avr_seg_time(c) = avr_seg_time(c) + seg_times(r,c); + divide_by_n(c) = divide_by_n(c) + 1; + end + end + end +end +%% Ta medel av summan +for c =1:seg_time_size(2) + avr_seg_time(c) = avr_seg_time(c)/divide_by_n(c); +end +%% Rita +subplot(20, 1, 13:20); Plot = bar(avr_seg_time); -%Plot.Marker = 'o'; Plot.FaceColor = 'k'; xlabel('Segment'); ylabel('Tid [s]'); -- cgit v1.2.1 From baa8c3c3ee9b98ef5ce258aacc316fcdf54c1c76 Mon Sep 17 00:00:00 2001 From: Albin Date: Wed, 23 Oct 2019 16:27:09 +0200 Subject: Tog bort nollraden i segment_times i main.m --- Kod/bilbana/yc4/main.m | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Kod/bilbana/yc4/main.m b/Kod/bilbana/yc4/main.m index 3bdf697..efadd55 100644 --- a/Kod/bilbana/yc4/main.m +++ b/Kod/bilbana/yc4/main.m @@ -79,8 +79,6 @@ while 1 car1.segment = 1; car1.lap = car1.lap + 1; - - car1.seg_times(car1.lap, 1) = 0; end %% CHECK LAP AND CHECKPOINT (CAR 2) @@ -113,8 +111,6 @@ while 1 car2.segment = 1; car2.lap = car2.lap + 1; - - car2.seg_times(car2.lap, 1) = 0; end %% CALCULATE (CAR 1) -- cgit v1.2.1 From b7771e858cb8bb753521792d828d7a5f47d175cd Mon Sep 17 00:00:00 2001 From: Albin Date: Fri, 25 Oct 2019 09:22:21 +0200 Subject: =?UTF-8?q?Bytte=20ut=20string()=20mot=20char()=20f=C3=B6r=20att?= =?UTF-8?q?=20funka=20med=20nyare=20matlabversioner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kod/bilbana/Graph/lap_time_graph.m | 6 +++--- Kod/bilbana/Graph/segment_time_graph.m | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Kod/bilbana/Graph/lap_time_graph.m b/Kod/bilbana/Graph/lap_time_graph.m index 8d54c6a..b75d3de 100644 --- a/Kod/bilbana/Graph/lap_time_graph.m +++ b/Kod/bilbana/Graph/lap_time_graph.m @@ -40,13 +40,13 @@ hold off %% Standardavvkielse sigma = std(lap_times); sigma = round(sigma, 2); -sig_str = string(sigma); +sig_str = char(sigma); %% Text xlabel('Varv'); ylabel('Tid [s]'); -Tit = join(['Varvtider bana',string(track)]); +Tit = char(['Varvtider bana',char(track)]); title(Tit); -txt = join(['Standardavvikelse:',sig_str, 's/varv']); +txt = char(['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 index 5ae0690..9ee4b8c 100644 --- a/Kod/bilbana/Graph/segment_time_graph.m +++ b/Kod/bilbana/Graph/segment_time_graph.m @@ -34,7 +34,7 @@ Plot = bar(avr_seg_time); Plot.FaceColor = 'k'; xlabel('Segment'); ylabel('Tid [s]'); -tit = join(['Medeltid/segment bana',string(track)]); +tit = char(['Medeltid/segment bana',char(track)]); title(tit); end -- cgit v1.2.1 From 14fdcb87f762f0c72ccc7324ba9f84625ec370a2 Mon Sep 17 00:00:00 2001 From: Albin Date: Fri, 25 Oct 2019 09:51:28 +0200 Subject: Bugfix seg_time_graph --- Kod/bilbana/Graph/graphs_test.m | 6 +++--- Kod/bilbana/Graph/segment_time_graph.m | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Kod/bilbana/Graph/graphs_test.m b/Kod/bilbana/Graph/graphs_test.m index 451bbf1..ddc3b64 100644 --- a/Kod/bilbana/Graph/graphs_test.m +++ b/Kod/bilbana/Graph/graphs_test.m @@ -5,10 +5,10 @@ A = [3.9,1.1,2.2,1.8,1.4,3.9,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, 0, 0, 0]; B = [3.9,1.1,2.2,1.8,1.4,3.9, 0, 0, 0]; -C = [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, 0, 0, 0]; +C = [3.9,1.1,2.2,1.8,1.4,3.9,1.5,3.1,1.0; + 4.1,1.1,2.2,1.8,1.4,3.4, 0, 0, 0]; car1.seg_times = C; 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,7) \ No newline at end of file +graphs(car1.lap_times,ref_lap_time,car1.seg_times,5) \ No newline at end of file diff --git a/Kod/bilbana/Graph/segment_time_graph.m b/Kod/bilbana/Graph/segment_time_graph.m index 9ee4b8c..5100693 100644 --- a/Kod/bilbana/Graph/segment_time_graph.m +++ b/Kod/bilbana/Graph/segment_time_graph.m @@ -13,7 +13,7 @@ divide_by_n = ones(1,seg_time_size(2)); %% Summera seg_time om seg_time ~= 0 for r = 1:seg_time_size(1) if r == 1 - avr_seg_time(1:seg_time_size(2)) = seg_times(1:seg_time_size(2)); + avr_seg_time(1,1:seg_time_size(2)) = seg_times(1,1:seg_time_size(2)); else for c = 1:seg_time_size(2) x = seg_times(r,c); -- cgit v1.2.1 From 785a87c8a5277abf09f44086b7dd05d2ebfb5af5 Mon Sep 17 00:00:00 2001 From: Albin Date: Fri, 25 Oct 2019 10:29:35 +0200 Subject: Bugfix graph. Text visas nu ordentligt --- Kod/bilbana/Graph/lap_time_graph.m | 6 +++--- Kod/bilbana/Graph/segment_time_graph.m | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Kod/bilbana/Graph/lap_time_graph.m b/Kod/bilbana/Graph/lap_time_graph.m index b75d3de..c21a0c5 100644 --- a/Kod/bilbana/Graph/lap_time_graph.m +++ b/Kod/bilbana/Graph/lap_time_graph.m @@ -40,13 +40,13 @@ hold off %% Standardavvkielse sigma = std(lap_times); sigma = round(sigma, 2); -sig_str = char(sigma); +sig_str = num2str(sigma); %% Text xlabel('Varv'); ylabel('Tid [s]'); -Tit = char(['Varvtider bana',char(track)]); +Tit = ['Varvtider bana ' num2str(track)]; title(Tit); -txt = char(['Standardavvikelse:',sig_str, 's/varv']); +txt = ['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 index 5100693..c32281a 100644 --- a/Kod/bilbana/Graph/segment_time_graph.m +++ b/Kod/bilbana/Graph/segment_time_graph.m @@ -34,7 +34,7 @@ Plot = bar(avr_seg_time); Plot.FaceColor = 'k'; xlabel('Segment'); ylabel('Tid [s]'); -tit = char(['Medeltid/segment bana',char(track)]); +tit = ['Medeltid/segment bana ' num2str(track)]; title(tit); end -- cgit v1.2.1