fitting data into a quadratic curve

12 visualizaciones (últimos 30 días)
Hadi Data
Hadi Data el 4 de Oct. de 2019
Comentada: Star Strider el 15 de Oct. de 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.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by