Hi all!
I need to fit following Power Law to some experimental data.
y = C(B+x)^n
The data I have is as the following:
STRESS = [0.574, 367.364, 449.112, 531.087, 596.241, 649.097, 695.038, 737.173, 815.008];
STRAIN = [2.8746e-04, 0.00063, 0.0459, 0.0901, 0.1320, 0.1725, 0.2132, 0.2557, 0.3579];
The variables are x and y are STRAIN and STRESS respectively, and I would like estimates for C, B and n.
I'm not sure how to use the fitting tool for this kind of specific model.
Any ideas or suggestions would be greatly appreciated!
Thank you very much!

2 commentaires

John D'Errico
John D'Errico le 6 Déc 2019
Modifié(e) : John D'Errico le 6 Déc 2019
One requirement is that you have the same number of values in each vector. You don't meet that basic requirement.
numel(STRESS)
ans =
8
numel(STRAIN)
ans =
9
Once you have actually told us the correct data, then you need to explain which variable is intended to be x, and which is y. If you want help, then make it possible, even easy, for someone to help you.
Tobias Bramminge
Tobias Bramminge le 6 Déc 2019
Thank you very much for your reply!
I am very sorry for the bad explanation, I am quite new at requesting help like this. I've updated the data and the variables are x and y.
Is this sufficient?

Connectez-vous pour commenter.

 Réponse acceptée

Star Strider
Star Strider le 6 Déc 2019
Modifié(e) : Star Strider le 6 Déc 2019

0 votes

Try this:
STRESS = [0.574, 367.364, 449.112, 531.087, 596.241, 649.097, 695.038, 737.173, 815.008];
STRAIN = [2.8746e-04, 0.00063, 0.0459, 0.0901, 0.1320, 0.1725, 0.2132, 0.2557, 0.3579];
yfcn = @(b,x) b(1).*(b(2)+x).^b(3);
B0 = [1E-6; 100; 2];
B = fminsearch(@(b) norm(STRAIN - yfcn(b,STRESS)), B0);
xv = linspace(min(STRESS), max(STRESS), 50);
yv = yfcn(B,xv);
figure
plot(STRESS, STRAIN, 'pg')
hold on
plot(xv, abs(yv), '-r')
hold off
grid
text(150, 0.27, sprintf('y = %.3E \\cdot (%.3f + x)^{%.3f}', B))
xlabel('STRESS')
ylabel('STRAIN')
Experiment to get different results.
EDIT (6 Dec 2019 at 17:50)
Added plot image:
1Fit Powerlaw to Data - 2019 12 06.png

7 commentaires

Tobias Bramminge
Tobias Bramminge le 6 Déc 2019
Thank you very much for your reply!
I forgot to mention which variable was STRESS and STRAIN, which I've just updated. But STRESS in y and STRAIN is x.
But compared to your answer I tried switching these around, but it doesn't quite follow.
I'm not quite sure what each step is doing.
Sorry for the inconvenience! I appreciate the quick reply tremendously!
Star Strider
Star Strider le 6 Déc 2019
My pleasure!
Corrected Code
STRESS = [0.574, 367.364, 449.112, 531.087, 596.241, 649.097, 695.038, 737.173, 815.008];
STRAIN = [2.8746e-04, 0.00063, 0.0459, 0.0901, 0.1320, 0.1725, 0.2132, 0.2557, 0.3579];
yfcn = @(b,x) b(1).*(b(2)+x).^b(3);
B0 = [500; 0.1; 0.1];
B = fminsearch(@(b) norm(STRESS - yfcn(b,STRAIN)), B0);
xv = linspace(min(STRAIN), max(STRAIN), 50);
yv = yfcn(B,xv);
figure
plot(STRAIN, STRESS, 'pg')
hold on
plot(xv, yv, '-r')
hold off
grid
text(0.17, 300, sprintf('y = %.3f \\cdot (%.3E + x)^{%.3f}', B))
xlabel('STRAIN')
ylabel('STRESS')
producing:
1Fit Powerlaw to Data - 2019 12 06.png
Tobias Bramminge
Tobias Bramminge le 6 Déc 2019
Thank you very much!
This is the method I was searching for.
Have a great weekend!
Star Strider
Star Strider le 6 Déc 2019
As always, my pleasure!
You have a great weekend, too!
Image Analyst
Image Analyst le 6 Déc 2019
Why are you trying to include the left most point in the fit? It basically ruins the fit for all the other points. It would be so much better if you didn't include it, like this:
0000 Screenshot.png
See how much closer the fit is for points 2-9 if you omit the first point? Will you ever really be trying to estimate values down in that region where the training data is nearly vertical? And, if so, it is worth getting a looser, worse fit over the majority of your range when you could avoid it with a piecewise fit?
vedavathi
vedavathi le 8 Mai 2021
r square value?
Star Strider
Star Strider le 8 Mai 2021
vedavathi — It is a straightforward calculation, however it is easier to use fitnlm with ‘yfcn’ to get that and a number of other statistics.

Connectez-vous pour commenter.

Plus de réponses (2)

Image Analyst
Image Analyst le 6 Déc 2019

0 votes

I'd use fitnlm() in the Statistics and Machine Learning Toolbox.
I suggest that you don't try to fit the first point. When I try to do that, it's impossible to get a fit. I get error messages that says the Jacobian is not well defined. "Warning: The Jacobian at the solution is ill-conditioned, and some model parameters may not be estimated well (they are not identifiable). Use caution in making predictions. " and it won't do the fit.
But if I try to fit from the second point onwards, I still get the warning but the fit seems reasonable. See plot below. If you want you could do a piece-wise fit where you fit everything to the left of the second point to a line.
0000 Screenshot.png

Catégories

En savoir plus sur Stress and Strain dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by