-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogData.m
46 lines (33 loc) · 1.36 KB
/
LogData.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
% A function to log results at each step of the MagnetLoc program.
% Results are logged to "log.txt", which can then be read by
% "PlotResults.m" for result display.
% Author: G. Garcia
function LogData( t , phase , X , P , U , Y )
persistent fid ;
if strcmp(phase,'init')
fid = fopen('log.txt','w') ;
fprintf( fid , 'calcPhase t x y theta P11 P12 P13 P22 P23 P33 U1 U2 y1 y2\n') ;
fprintf( fid , '0 ' ) ;
fprintf( fid , '%8f ' , ...
[t, X(1),X(2),X(3) , P(1,1),P(1,2),P(1,3),P(2,2),P(2,3),P(3,3) , 0,0 , 0,0 ] ) ;
fprintf( fid , '\n' ) ;
elseif strcmp(phase,'prediction')
fprintf( fid , '1 ' ) ;
fprintf( fid , '%8f ' , ...
[t, X(1),X(2),X(3) , P(1,1),P(1,2),P(1,3),P(2,2),P(2,3),P(3,3) , U(1),U(2) , 0,0 ] ) ;
fprintf( fid , '\n' ) ;
elseif strcmp(phase,'measurement')
fprintf( fid , '2 ' ) ;
fprintf( fid , '%8f ' , ...
[t, X(1),X(2),X(3) , P(1,1),P(1,2),P(1,3),P(2,2),P(2,3),P(3,3) , 0,0 , Y(1),Y(2) ] ) ;
fprintf( fid , '\n' ) ;
elseif strcmp(phase,'update')
fprintf( fid , '3 ' ) ;
fprintf( fid , '%8f ' , ...
[t, X(1),X(2),X(3) , P(1,1),P(1,2),P(1,3),P(2,2),P(2,3),P(3,3) , 0,0 , 0,0 ] ) ;
fprintf( fid , '\n' ) ;
elseif strcmp(phase,'termination')
fclose(fid) ;
else
error('Incorrect phase specification in "logData".');
end