-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotSpeedTime.m
42 lines (35 loc) · 1.35 KB
/
plotSpeedTime.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
% [[file:mutual_ide.org::*Speed vs. time plot][Speed vs. time plot:1]]
function plotSpeedTime(simMatFile, varargin)
p = inputParser;
addRequired(p, 'simMatFile');
addOptional(p,'createFile', true, @islogical);
addOptional(p, 'figDir', './', @isfolder);
parse(p, simMatFile, varargin{:});
filename = simMatFile.filename;
iterations = simMatFile.iterations;
instantSpeedP = simMatFile.instantSpeedP;
instantSpeedF1 = simMatFile.instantSpeedF1;
instantSpeedF2 = simMatFile.instantSpeedF2;
if p.Results.createFile
f = figure('visible', 'off');
else
f = figure(1);
end
% plot(1:iterations, instantSpeedP(1:iterations), 1:iterations, instantSpeedF1(1:iterations), 1:iterations, instantSpeedF2(1:iterations));
hold on
plot(instantSpeedP(1:iterations), LineWidth=1.5);
plot(instantSpeedF1(1:iterations), LineWidth=1.5);
plot(instantSpeedF2(1:iterations), LineWidth=1.5);
legend('P', 'F1', 'F2');
% title(strcat(['Spread speed vs. time']));
xlabel('iterations');
ylabel('speed');
hold off
if p.Results.createFile
[~, filename, ~] = fileparts(filename);
filename = fullfile(p.Results.figDir, strcat('speed_time_', filename));
saveas(f, strcat(filename, '.fig'));
saveas(f, strcat(filename, '.png'));
end
end
% Speed vs. time plot:1 ends here