fitting data into a quadratic curve

12 Ansichten (letzte 30 Tage)
Hadi Data
Hadi Data am 4 Okt. 2019
Kommentiert: Star Strider am 15 Okt. 2019
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.

Akzeptierte Antwort

Star Strider
Star Strider am 4 Okt. 2019
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 Kommentare
Hadi Data
Hadi Data am 15 Okt. 2019
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
Star Strider am 15 Okt. 2019
As always, my pleasure!
That is actually what Answers is for!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by