-
Notifications
You must be signed in to change notification settings - Fork 0
/
prob_saveas_csv.m
38 lines (34 loc) · 1.26 KB
/
prob_saveas_csv.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
% Copyright 2021, C. Minz. BSD 3-Clause License.
function prob_saveas_csv( filename, hits, yaxisscale, xvalues )
if nargin < 4
yaxisscale = 1;
end
if yaxisscale >= 2
% save to data file, y-axis in log scale:
fileID = fopen( sprintf( '%s.%s', filename, 'log.csv' ), 'w' );
for i = 1 : length( hits )
logvalue = log( avhits( i ) );
if ~isnan( logvalue ) && ~isinf( logvalue ) && ( logvalue > 0 )
if nargin < 5
fprintf( fileID, '%d, %0.5f\n', i, log( logvalue ) );
else
fprintf( fileID, '%d, %0.5f\n', xvalues( i ), log( logvalue ) );
end
end
end
fclose( fileID );
yaxisscale = floor( ( yaxisscale - 1 ) / 2 );
end
if yaxisscale >= 1
% save to data file, y-axis in linear scale:
fileID = fopen( sprintf( '%s.%s', filename, 'csv' ), 'w' );
for i = 1 : length( hits )
if nargin < 5
fprintf( fileID, '%d, %0.5f\n', i, avhits( i ) );
else
fprintf( fileID, '%d, %0.5f\n', xvalues( i ), avhits( i ) );
end
end
fclose( fileID );
end
end