Hello,
I am currently putting the state of the art to generate material models for sheet metal forming into Matlab.
I have two fits with different approaches to the same set of data points (Swift, HockettSherby). They behave very different when the data points end and the extrapolation begins.
To better fit the extrapolation to reality, a second set of data points is generated, delivering values within that extrapolation area.
Finally, the two approaches are superimposed, using the factor alpha, to better fit the second set of data points.
As you can see within my code, to calculate alpha I am currently retreiving the coefficients from the results of my Swift and HockettSherby fits. Afterwards, I use the same formulas I used to create the Swift and HockettSherby fit to fit my alpha value.
My question is:
Is there a better way to reuse the formula and the coefficient of a cfit objekt for further calculations?
Thanks for your help!
Timif true
% code
% data points taken from my measurements
x1 = [0.0020 0.0026 0.0033 0.0039 0.0046 0.0052 0.0059 ...
0.0066 0.0073 0.0080 0.0087 0.0094 0.0101 0.0108 ...
0.0115 0.0123 0.0130 0.0137 0.0144 0.0151 0.0158 ...
0.0166 0.0173 0.0180 0.0187 0.0194 0.0202 0.0209 ...
0.0216 0.0223 0.0230 0.0238 0.0245 0.0252 0.0259 ...
0.0266 0.0273 0.0281 0.0288 0.0295 0.0302 0.0309 ...
0.0317 0.0324 0.0331 0.0338 0.0345 0.0352 0.0360 ...
0.0367 0.0374 0.0381];
y1 = [793.7 821.7 844.6 863.8 880.3 894.7 907.4 ...
918.5 928.6 937.6 945.6 952.9 959.6 965.7 ...
971.3 976.5 981.3 985.8 989.9 993.9 997.5 ...
1000.9 1004.1 1007.2 1010.1 1012.8 1015.3 1017.7 ...
1020.0 1022.2 1024.3 1026.3 1028.2 1030.1 1031.7 ...
1033.4 1035.0 1036.5 1038.0 1039.4 1040.8 1042.1 ...
1043.3 1044.5 1045.6 1046.7 1047.8 1048.9 1049.8 ...
1050.8 1051.6 1052.5];
% even more data points taken from my measurments
x2 = [0.0223 0.0295 0.0366 0.0479 0.0611 0.0744 0.0877 ...
0.1010 0.1143 0.1276 0.1408 0.1541 0.1674 0.1807 ...
0.1940 0.2073 0.2205 0.2338 0.2471 0.2604 0.2737 ...
0.2870 0.3002 0.3135 0.3268 0.3401 0.3534 0.3667 ...
0.3799 0.3932 0.4065 0.4198 0.4331 0.4464 0.4596 ...
0.4729 0.4862 0.4995 0.5128 0.5261 0.5393 0.5526 ...
0.5659 0.5792 0.5925 0.6058 0.6190 0.6323 0.6456 ...
0.6589];
y2 = [1022.2 1039.4 1050.7 1071.1 1092.7 1108.4 1120.2 ...
1128.2 1149.3 1158.3 1164.9 1167.9 1183.0 1190.6 ...
1196.8 1200.2 1212.8 1217.3 1224.7 1226.3 1234.4 ...
1238.8 1243.9 1247.2 1252.1 1261.9 1265.1 1270.7 ...
1277.0 1277.8 1280.3 1286.4 1291.3 1297.9 1300.6 ...
1307.8 1311.3 1313.4 1316.8 1323.1 1329.1 1331.7 ...
1336.3 1343.1 1349.8 1353.3 1358.6 1363.0 1369.4 ...
1373.0];% prepare the input data for curve fitting
[x1Data, y1Data] = prepareCurveData(x1,y1);
[x2Data, y2Data] = prepareCurveData(x2,y2);% fit Swift
ftSwift = fittype( 'a*(x+b)^c', 'independent', 'x', 'dependent', 'y' );
optSwift = fitoptions( 'Method', 'NonlinearLeastSquares' );
optSwift.Algorithm = 'Trust-Region';
optSwift.Display = 'Off';
optSwift.Lower = [0 0 0];
optSwift.Robust = 'off';
optSwift.Upper = [5000 10 1];
optSwift.TolFun = 1*10^(-10);
optSwift.TolX = 1*10^(-10);
optSwift.DiffMinChange = 1*10^(-10);
[fitSwift, gofSwift, outputSwift] = fit(x1Data, y1Data, ftSwift, optSwift);% fit HockettSherby
ftHS = fittype( 'a-b*exp(-c*x^d)', 'independent', 'x', 'dependent', 'y' );
optHS = fitoptions( 'Method', 'NonlinearLeastSquares' );
optHS.Algorithm = 'Trust-Region';
optHS.Display = 'Off';
optHS.Lower = [0 0 0 0];
optHS.Robust = 'off';
optHS.StartPoint = [200 1000 0.01 0.0001];
optHS.Upper = [5000 5000 100 1];
[fitHS, gofHS, outputHS] = fit(x1Data, y1Data, ftHS, optHS);% Get coefficients out of the fitsC_Swift(1) = fitSwift.a;
C_Swift(2) = fitSwift.b;
C_Swift(3) = fitSwift.c;
C_Hockett_Sherby(1) = fitHS.a;
C_Hockett_Sherby(2) = fitHS.b;
C_Hockett_Sherby(3) = fitHS.c;
C_Hockett_Sherby(4) = fitHS.d;% calculate alpha of this equation alpha*Swift + (1-alpha)*HockettSherby
F = @(alpha, x) alpha*(C_Swift(1)*(x + C_Swift(2)).^C_Swift(3)) + (1-alpha)*(C_Hockett_Sherby(1)-C_Hockett_Sherby(2)*exp(-C_Hockett_Sherby(3)*x.^C_Hockett_Sherby(4)));
alpha_0 = 0.5;
[alpha,~,~,~,~,~,~] = lsqcurvefit(F,alpha_0,x2Data,y2Data,0,1);% Generate Date to plot the final fit
x = [0:0.01:0.7];
y = F(alpha, x);% plot all curves
figure;
plot(x1,y1,'*'); % Data points 1
hold on;
plot(x2,y2, '+'); % Data points 2
plot(fitSwift, 'b') % fit Swift
plot(fitHS, 'g') % fit HockettSherby
plot(x,y); % fit alpha Swift hockettSherby
legend('y1', 'y2', 'fit Swift', 'fit hockettSherby', 'fit alpha Swift HockettSherby', 'Location', 'south')
end