fitting data into a quadratic curve
12 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Star Strider
on 4 Oct 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 Comments
More Answers (0)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!