Second degree polynomial fit
Mostrar comentarios más antiguos
Hi everyone,
R = c0-c1*(Tp)+c2*(Tp)^2,
I have a second degree polynomial function, where I have to fit the three constants (c0,c1,c2) The values for R and Tp are fixed, where R=998.9 and Tp=24.0 Can anyone help me out with this problem?
Regards,
Marc
Respuestas (1)
Star Strider
el 22 de Jul. de 2016
Editada: Star Strider
el 22 de Jul. de 2016
You have one equation in three unknowns, so there are an infinity of solutions. The solution you get depends on your initial parameter estimates:
R=998.9;
Tp=24.0;
f = @(c) c(1) - c(2).*Tp + c(3).*Tp^2 - R;
C0 = [1; 1; 1];
C = fsolve(f, C0)
One set of solutions with this ‘C0’:
C =
1.0013
0.9678
1.7728
8 comentarios
Steven Lord
el 22 de Jul. de 2016
I'd probably just fix two of the coefficients and solve for the third. This process is particularly easy (but probably not what the poster wanted) if you fix c(2) and c(3) to be 0.
Something probably closer to what they want might be to fix c(1) and c(2) to be 0 and solve for c(3). That's a fairly straightforward task, no MATLAB needed.
If they had enough (Tp, R) pairs of values, they could use the polyfit function.
Maarten van Sommeren
el 23 de Jul. de 2016
Star Strider
el 23 de Jul. de 2016
My pleasure.
Using the same value of ‘Tp’ for all of them would be a problem.
I would do it this way, although it will not give you any useful information:
Tp=24.0; % Define ‘Tp’
R = 998.9:10:1040; % Create Data
c = polyfit(Tp*ones(size(R)), R, 2); % Estimate ‘c’
Substitute your own vector of ‘R’ for the vector I used to test this.
Image Analyst
el 23 de Jul. de 2016
A polynomial has an x, a y, and a set of coefficients. With polyfit() you pass in x and y and get coefficients out. In the polynomial that you imagine getting out of this, what would be your x - Tp, R, or the c? What would be your y - Tp, R, or the c?
For what it's worth, I attach my polyfit demo.
Star Strider
el 23 de Jul. de 2016
‘Answer by Maarten van Sommeren 38 minutes ago’ moved here:
I would say that R = y and Tp = x. A possibility is to fix the values for c0 and c1 as the literature says they would be very small. So that would mean I can easily calculate c2. Is there a way I could fit the constants for c0 and c1 when c2 is known? Maybe this will clarify my problem
Star Strider
el 23 de Jul. de 2016
If ‘c0’ and ‘c1’ are negligibly small, ‘c2’ becomes ‘R/(Tp^2)’. I would just then take the mean and standard deviation of the 5 calculated ‘c2’ values.
If you only have one value for ‘Tp’, regardless of the number of values for ‘R’ you have, you still cannot do a meaningful regression.
Maarten van Sommeren
el 25 de Jul. de 2016
Star Strider
el 25 de Jul. de 2016
My pleasure!
With only one value of ‘Tp’, regardless of the number of ‘R’ values you have, they are arbitrary. Choose a value for ‘c0’, then:
c1 = c0/Tp;
Since you’ve already calculated ‘c2’ from ‘Tp’ and ‘R’, neglecting ‘c0’ and ‘c1’ (assuming they are negligible), the remaining terms have to equate to 0.
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!