Second degree polynomial fit
이전 댓글 표시
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
답변 (1개)
Star Strider
2016년 7월 22일
편집: Star Strider
2016년 7월 22일
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
Steven Lord
2016년 7월 22일
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
2016년 7월 23일
Star Strider
2016년 7월 23일
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
2016년 7월 23일
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
2016년 7월 23일
‘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
2016년 7월 23일
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
2016년 7월 25일
Star Strider
2016년 7월 25일
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.
카테고리
도움말 센터 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!