I have no clear idea what you want to do.
This approach fits all the parameters at once —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1201063/ReqFittingData.xlsx', 'VariableNamingRule','preserve')
T1 =
SoC 0.8Vi 0.85Vi 0.9Vi 0.95Vi 1Vi
___ ______ ______ ______ ______ ______
5 60.989 57.342 54.322 51.526 50.204
10 60.212 56.618 53.619 50.862 49.53
15 59.832 56.268 53.278 50.53 49.205
20 59.334 55.776 52.813 50.061 48.783
25 58.914 55.404 52.422 49.712 48.434
30 58.567 55.057 52.131 49.431 48.144
35 58.187 54.701 51.772 49.087 47.813
40 58.012 54.567 51.637 48.956 47.708
45 57.91 54.439 51.523 48.86 47.59
50 57.79 54.318 51.407 48.758 47.474
55 57.644 54.191 51.278 48.613 47.346
60 57.532 54.066 51.181 48.509 47.242
65 57.384 53.956 51.07 48.427 47.143
70 57.25 53.79 50.946 48.31 47.033
75 57.157 53.707 50.825 48.184 46.918
80 57.075 53.64 50.785 48.141 46.864
VN = T1.Properties.VariableNames
VN =
{'SoC'} {'0.8Vi'} {'0.85Vi'} {'0.9Vi'} {'0.95Vi'} {'1Vi'}
Viv = regexp([VN{:}], '(\d*\.\d*)|\d*', 'match')
Viv =
{'0.8'} {'0.85'} {'0.9'} {'0.95'} {'1'}
Viv = str2double(Viv)
Viv =
0.8000 0.8500 0.9000 0.9500 1.0000
Vivm = repmat(Viv, size(T1,1), 1);
SoCv = repmat(T1.SoC, size(Viym,2), 1)
SoCv =
5
10
15
20
25
30
35
40
45
50
objfcn = @(b,x) exp(b(1)).*x(:,1).^b(2) + b(3).*x(:,2);
mdl = fitnlm(x, y, objfcn, rand(3,1))
mdl =
Nonlinear regression model:
y ~ exp(b1)*x1^b2 + b3*x2
Estimated Coefficients:
Estimate SE tStat pValue
_________ __________ _______ ___________
b1 4.6505 0.0067979 684.11 2.3549e-228
b2 -0.014195 0.00067264 -21.103 2.4122e-43
b3 -52.331 0.72897 -71.788 1.1374e-104
Number of observations: 130, Error degrees of freedom: 127
Root Mean Squared Error: 0.588
R-Squared: 0.978, Adjusted R-Squared 0.977
F-statistic vs. zero model: 3.4e+05, p-value = 1.03e-247
An alternative approach uses a loop to fit each column individually —
B0 = mdl.Coefficients.Estimate;
mdl = fitnlm(x, y, objfcn, B0)
end
x =
5.0000 0.8000
10.0000 0.8000
15.0000 0.8000
20.0000 0.8000
25.0000 0.8000
30.0000 0.8000
35.0000 0.8000
40.0000 0.8000
45.0000 0.8000
50.0000 0.8000
y =
60.9887
60.2122
59.8316
59.3342
58.9138
58.5672
58.1869
58.0121
57.9105
57.7896
Warning: Iteration limit exceeded. Returning results from final iteration.
mdl =
Nonlinear regression model:
y ~ exp(b1)*x1^b2 + b3*x2
Estimated Coefficients:
Estimate SE tStat pValue
_________ ________ ________ _______
b1 5.0195 3.948 1.2714 0.21629
b2 -0.010636 0.043594 -0.24397 0.80942
b3 -109.3 746.47 -0.14643 0.88486
Number of observations: 26, Error degrees of freedom: 23
Root Mean Squared Error: 0.117
R-Squared: 0.992, Adjusted R-Squared 0.991
F-statistic vs. constant model: 1.37e+03, p-value = 1.25e-24
x =
5.0000 0.8500
10.0000 0.8500
15.0000 0.8500
20.0000 0.8500
25.0000 0.8500
30.0000 0.8500
35.0000 0.8500
40.0000 0.8500
45.0000 0.8500
50.0000 0.8500
y =
57.3419
56.6183
56.2681
55.7763
55.4043
55.0568
54.7007
54.5669
54.4393
54.3177
Warning: Iteration limit exceeded. Returning results from final iteration.
mdl =
Nonlinear regression model:
y ~ exp(b1)*x1^b2 + b3*x2
Estimated Coefficients:
Estimate SE tStat pValue
_________ ________ ________ _______
b1 4.9841 4.0116 1.2424 0.2266
b2 -0.010412 0.043331 -0.2403 0.81223
b3 -101.15 689.07 -0.14679 0.88457
Number of observations: 26, Error degrees of freedom: 23
Root Mean Squared Error: 0.11
R-Squared: 0.992, Adjusted R-Squared 0.991
F-statistic vs. constant model: 1.38e+03, p-value = 1.08e-24
x =
5.0000 0.9000
10.0000 0.9000
15.0000 0.9000
20.0000 0.9000
25.0000 0.9000
30.0000 0.9000
35.0000 0.9000
40.0000 0.9000
45.0000 0.9000
50.0000 0.9000
y =
54.3216
53.6187
53.2782
52.8128
52.4222
52.1308
51.7724
51.6367
51.5228
51.4068
Warning: Iteration limit exceeded. Returning results from final iteration.
mdl =
Nonlinear regression model:
y ~ exp(b1)*x1^b2 + b3*x2
Estimated Coefficients:
Estimate SE tStat pValue
_________ ________ ________ _______
b1 4.9387 3.9118 1.2625 0.21941
b2 -0.010408 0.042233 -0.24645 0.80752
b3 -91.846 606.51 -0.15143 0.88095
Number of observations: 26, Error degrees of freedom: 23
Root Mean Squared Error: 0.102
R-Squared: 0.992, Adjusted R-Squared 0.991
F-statistic vs. constant model: 1.46e+03, p-value = 6.04e-25
x =
5.0000 0.9500
10.0000 0.9500
15.0000 0.9500
20.0000 0.9500
25.0000 0.9500
30.0000 0.9500
35.0000 0.9500
40.0000 0.9500
45.0000 0.9500
50.0000 0.9500
y =
51.5259
50.8622
50.5304
50.0606
49.7115
49.4312
49.0868
48.9559
48.8601
48.7579
Warning: Iteration limit exceeded. Returning results from final iteration.
mdl =
Nonlinear regression model:
y ~ exp(b1)*x1^b2 + b3*x2
Estimated Coefficients:
Estimate SE tStat pValue
_________ ________ ________ _______
b1 4.9102 3.9509 1.2428 0.22647
b2 -0.010229 0.041892 -0.24418 0.80926
b3 -85.939 564.01 -0.15237 0.88022
Number of observations: 26, Error degrees of freedom: 23
Root Mean Squared Error: 0.0967
R-Squared: 0.992, Adjusted R-Squared 0.992
F-statistic vs. constant model: 1.48e+03, p-value = 5.01e-25
x =
5 1
10 1
15 1
20 1
25 1
30 1
35 1
40 1
45 1
50 1
y =
50.2041
49.5297
49.2049
48.7825
48.4339
48.1437
47.8131
47.7076
47.5903
47.4742
Warning: Iteration limit exceeded. Returning results from final iteration.
mdl =
Nonlinear regression model:
y ~ exp(b1)*x1^b2 + b3*x2
Estimated Coefficients:
Estimate SE tStat pValue
_________ ________ ________ _______
b1 4.9107 3.9557 1.2414 0.22696
b2 -0.010039 0.041135 -0.24405 0.80936
b3 -83.087 536.75 -0.1548 0.87833
Number of observations: 26, Error degrees of freedom: 23
Root Mean Squared Error: 0.0933
R-Squared: 0.993, Adjusted R-Squared 0.992
F-statistic vs. constant model: 1.54e+03, p-value = 3.3e-25
The ‘objfun’ function uses a simple power relation and adds a term for the ‘Vi’ value.
I am not certain how the ‘Vi’ values relate the the ‘Eqivalent Resistance’, or for that matter what these data are. So this is essentially a prototype approach to demonstrate how to incorporate all the necessary data, even though I’m not certain how to correctly incorporate it.
I defer to you to determine the desiured result, and how to actually get it.
.