fitting data into a quadratic curve
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hello,
I have some data that can be fitted into a quadratic curve of y=ax^2 + bx + c. My data passes through the origin, and has a horizontal slope near the origin too. So my question is how do i force b and c to be zero in the qudratic equation ? while doing that i want to estimate the error too, so how do i keep track of the error if i have more than one quadratic equation.
I tried using fittype and polyval, and i am familiar with them, but that doesn't do my task.
I attached my data for better understanding.
Thanks for any help.
채택된 답변
Star Strider
2019년 10월 4일
To force ‘b’ and ‘c’ to be zero:
B = volume_flow_rate1(:).^2 \ influence(:) % Estimate Regression Parameter
vfrv = linspace(min(volume_flow_rate1), max(volume_flow_rate1)); % Vector For Regression Evaluation
inflv = vfrv(:).^2 * B; % Evaluate Regression
figure();
plot(volume_flow_rate1,influence, '--r*' );
hold on
plot(vfrv, inflv, '-.k') % Plot Regression
hold off
xlabel ('Q (uL/s)');
ylabel ('P(Pa)');
legend ('Via');
text(25, 1200, sprintf('y = %.6f\\cdotx^2', B)) % Regression Equation
The regression parameter is:
B =
0.0266527362537937
To force only ‘c’ to be zero:
B = [volume_flow_rate1(:).^2, volume_flow_rate1(:)] \ influence(:); % Estimate Regression Parameters
vfrv = linspace(min(volume_flow_rate1), max(volume_flow_rate1)); % Vector For Regression Evaluation
inflv = [vfrv(:).^2, vfrv(:)] * B; % Evaluate Regression
figure();
plot(volume_flow_rate1,influence, '--r*' );
hold on
plot(vfrv, inflv, '-.k') % Plot Regression
hold off
xlabel ('Q (uL/s)');
ylabel ('P(Pa)');
legend ('Via');
text(25, 1200, sprintf('y = %.6f\\cdotx^2 %+.6f\\cdotx', B)) % Regression Equation
The regression parameter estimates are:
B =
0.0304986880886496
-0.722814145120915
댓글 수: 10
Hadi Data
2019년 10월 4일
Thank you for the great answer, that does the job perfectly. After plotting the regression paramter, i want now to estimate the error, how can i do that ?
My pleasure.
It depends on what you mean by ‘error’. To calculate the residuals and their standard deviations:
rsd = influence(:) - (volume_flow_rate1(:).^2 * B); % Residuals
std_rsd = std(rsd) % Standard Deviation Of Residuals
Hadi Data
2019년 10월 7일
Hello Star strider,
Thanks for the help out there. It helped a lot. I have a few more questions regarding the residuals, so if you may please.
In another plot, i fitted a quadratic curve to my data, where b and c does not equal to zero. I used fittype('poly2') for this. What i am trying to do now is to calculate the residuals of this fit. how can i do that ? what should i substract from the influence?
I can go through tools and then plot the residuals and calcualte the norm, but i decided to go with the standard deviation of the residuals as a comparison
Another small question regarding the estimation of the regression parameter. Is this a general method ? does it have a specific name? or am i asking a wrong question ?
Thanks again for the help.
Star Strider
2019년 10월 7일
As always, my pleasure!
I do not have the Curve Fitting Toolbox, so I cannot help you with any questions related directly to it.
Calculate the residuals by finding the values of the fitted curve at every value of the independent variable, then subtract that value from the data value at the same point.
The term ‘parameter estimation’ is the general term for determining the parameters of a model related to data. That is the only description I have ever encountered. There are several ways to estimate parameters, depending on the technique or algorithm used. Most of them minimise the squared distance between the data and the estimated model at each data value, although there are other methods of comparing them.
Hadi Data
2019년 10월 7일
I attached the m file with this reply. i am stuck on the "%Residuals" section of the quadratic curve. The thing is i don't know how to transform a fittype into double inorder to subtract it from the original data. Any help on this part ?
For the perimeter estimation, you used the method where it minimize the squared distance between the data and the estimated model at each data value, right ?
Thank youuu.
As always, my pleasure.
I do not have the Curve Fitting Toolbox, so I cannot help you with anything regarding it.
Doing the same thing with polyfit and polyval:
B = polyfit(volume_flow_rate1(:), influence(:), 2); % Estimate PArameters
infl_fit = polyval(B, volume_flow_rate1(:)); % Evaluate At Independent Variable Values
resid = influence(:) - infl_fit(:); % Calculate Residuals
You can then do statistics on the residuals.
Hadi Data
2019년 10월 15일
Hello Star strider,
As i can see you are an expert in fitting curves and codes that are related to this topic, so i thought i would ask you directlty here, and thank you inadvance.
I want to fit a power function y = a.x^b +c. Based on my data, b is always -1, but the fitting is giving values approximatly = -1. How do i force it to be -1 ?
Thank youuuu.
As always, my pleasure.
You will have problems with that, since:
volume_flow_rate1(1) = 0
However if you are using different data, I would calculate it as:
B = [1./x(:) ones(size(x(:)))] \ y(:) % Estimate Parameters
y_fit = [1./x(:) ones(size(x(:)))] * B % Fit To Data
This uses
which is more efficient than
.
which is more efficient than
Hadi Data
2019년 10월 15일
Perfect, that worked as i wanted. And yes i am using different data.
Thank you again and again :D , I learned alot from you.
Star Strider
2019년 10월 15일
As always, my pleasure!
That is actually what Answers is for!
추가 답변 (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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
