function plot_nedc_BOP_2A()
%plot_nedc_BOP_2A Plot the contents of nedc_BOP_2A.mat.
%   plot_nedc_BOP_2A is a MATLAB function for plotting thE
%   contents of the MATLAB data file nedc_BOP_2a.mat. For
%   further help, please inspect the file's contents.

% Define data file, load it, and check it's the right thing.
filename = 'nedc_BOP_2A.mat';
Data = load(filename);
expectedFields = {'T_nedc_BOP_2A', 'I_nedc_BOP_2A', 'V_nedc_BOP_2A'};
fieldsFound = cellfun(@(f)isfield(Data,f), expectedFields);
if ~all(fieldsFound)
    id = [mfilename ':expectedFieldsMissing'];
    msg = 'Expected fields missing.  Please check data file.';
    ME = MException(id, msg);
    throwAsCaller(ME);
end

% Set up figure for plotting.
hFig = gcf();
clf(hFig);
subplot(211)
axis1 = gca();
subplot(212)
axis2 = gca();
theAxes = [axis1 axis2];
clear axis1 axis2

% Make the voltage plot.
plot(theAxes(1), Data.T_nedc_BOP_2A/3600, Data.V_nedc_BOP_2A)
ylabel(theAxes(1), 'load voltage (V)');
ylim(theAxes(1), [1.4 2.6]);
set(theAxes(1), 'YTick', 1.4:0.2:2.6);
grid(theAxes(1), 'on');

% Make the current plot.
plot(theAxes(2), Data.T_nedc_BOP_2A/3600, -Data.I_nedc_BOP_2A)
ylabel(theAxes(2), 'discharge current (A)');
grid(theAxes(2), 'on');
ylim(theAxes(2), [0 2.0]);
set(theAxes(2), 'YTick', 0:0.5:2.0);

% Add the title and common data.
title(theAxes(1), filename, 'Interpreter', 'none')
linkaxes(theAxes, 'x');
arrayfun(@(a)xlabel(a, 'time (hours)'), theAxes);
arrayfun(@(a)set(a, 'XTick', 0:1:12), theAxes);

% % Save an image.
% print -dpng -r220 nedc_BOP_2A.png
