-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathValidate_Model_Order.m
More file actions
93 lines (69 loc) · 2.67 KB
/
Validate_Model_Order.m
File metadata and controls
93 lines (69 loc) · 2.67 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
%% Load dependencies
disp('Change Current Folder to active file name location');
cd (fileparts(matlab.desktop.editor.getActiveFilename));
disp('adding... ./Lib path');
addpath('./Lib');
%% Load data to workspace from dataset
% The included tests were performed at the University of Wisconsin-Madison
% by Dr. Phillip Kollmeyer (phillip.kollmeyer@gmail.com).
% Five pulse discharge HPPC test (0.5, 1, 2, 4, 6C) performed at 100, 95,
% 90, 80, 70..., 30, 25, 20, 15, 10, 5, 0 % SOC.
% The logged data file only includes the pulses, and does not include the
% subsequent discharges between the pulses, refer to the amp-hour data to
% determine the SOC for each pulse set.
disp('loading ... Five pulse discharge HPPC test Data');
load('Panasonic-18650PF-Data/Panasonic 18650PF Data/25degC/5 pulse disch/03-11-17_08.47 25degC_5Pulse_HPPC_Pan18650PF.mat');
Current = [ meas.Time, meas.Current];
Voltage = meas.Voltage;
Time = meas.Time;
%% Rescue flanks positions
% Rescato las posiciones del vector Current donde hay flancos.
flancos = flanks(meas.Current, 50);
i = 1;
for( n = 1 : length(flancos) )
if(flancos(n) == 1)
index(i).s = n; %index(i).Start
end
if (flancos(n) == - 1)
index(i).e = n; %index(i).End
i = i+1;
end
end
%% Selecting the Number of R-C Branches
% Tomo el n semiperiodo de relajaci�n para ajustar una curva
% polinomial y decidir que orden utilizar.
n = 10;
sample_v = Voltage(index(n).s : index(n).e);
sample_time = Time (index(n).s : index(n).e);
plot(sample_time,sample_v)
% Fit: 'Eq_RC_Circuit'.
[xData, yData] = prepareCurveData( sample_time, sample_v );
% Set up fittype and options.
% exp1 => Y = a*exp(b*x)
ft1 = fittype( 'exp1' );
opts1 = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts1.Display = 'Off';
opts1.Normalize = 'on';
opts1.StartPoint = [-0.00080023 -3.5629];
% Fit model to data.
[fitresult1, gof] = fit( xData, yData, ft1, opts1 );
% Set up fittype and options.
% exp2 => Y = a*exp(b*x)+c*exp(d*x)
ft = fittype( 'exp2' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.Normalize = 'on';
opts.StartPoint = [4.0866 -1.1738e-05 -0.00080023 -3.5629];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
% Plot fit vs data and conclude.
figure( 'Name', 'exp orden 2' );
title('Curve fit to determine number of R-C model branches')
h = plot( fitresult, xData, yData, 'b.');
hold on;
hg = plot( fitresult1, 'c--' );
legend( [h;hg], 'experimental data', 'exp2 aproximation', 'exp1 aproximation', 'Location', 'NorthEast' );
xlabel ('time [s]');
ylabel ('Voltage [v]');
grid on
%%