]> rtime.felk.cvut.cz Git - eurobot/public.git/blobdiff - src/timing/analyse.m
timing: matlab scripts
[eurobot/public.git] / src / timing / analyse.m
diff --git a/src/timing/analyse.m b/src/timing/analyse.m
new file mode 100644 (file)
index 0000000..ee85ae3
--- /dev/null
@@ -0,0 +1,39 @@
+file_app = fopen('trace.txt','r');
+
+if file_app == -1
+       error('File trace.txt cannot be opened for reading!');
+end
+
+for i=1:1
+    readin = fgetl(file_app);
+end
+
+i = 1;
+timestamps=zeros(5,2);
+
+while 1
+    readin = fgetl(file_app);
+    a = textscan(readin, '%d %n','delimiter',':');
+    if(a{1,1} == 0)
+        break;
+    end
+    timestamps(i, 1) = a{1, 1};
+    timestamps(i, 2) = (a{1,2});
+    i=i+1;
+end 
+
+timestamps_nr=size(timestamps,1);
+
+timestamps_diff=zeros(timestamps_nr/2,1);
+
+starts=zeros(timestamps_nr/2,1);
+ends=zeros(timestamps_nr/2,1);
+i=2;
+for j=1:timestamps_nr/2
+    timestamps_diff(j) = timestamps(i,2) - timestamps(i-1,2);
+    i = i + 2;
+end
+
+timestamps_diff = timestamps_diff.*1000000;
+
+fclose(file_app);
\ No newline at end of file