Hello, Quadratic and power curve fitting
1 view (last 30 days)
Show older comments
pressure=[10 15 25 40 50 55];
flow=[94 116 147 183 215 220];
a = -0.0170 ; b = 3.8870 ; c = 59.0062 ;
p = 5 : 60 ;
f = 5 : 300 ;
f_par = a* p.^ 2 +b * p + c
alpha = 72.0144 ; beta = 2.7842 ;
f_exp = alpha * p.^beta;
plot (pressure,flow,'o',p,f_par,p,f_exp,'--')
legend ('eperimental data','parabolic fit','exponential fit')
xlabel ('pressure psi') , ylabel ('flow gpm'),grid
Could some one correct my code where Y axis (f = flow rate) would stop plotting at value 400. currently it plots to 7*10^6.
thank you very much
0 Comments
Answers (1)
John D'Errico
on 18 Mar 2018
Edited: John D'Errico
on 18 Mar 2018
What do you expect? As you generated it, we see:
f_exp
f_exp =
Columns 1 through 13
6360.5 10567 16231 23540 32675 43815 57130 72791 90962 1.1181e+05 1.3549e+05 1.6215e+05 1.9197e+05
Columns 14 through 26
2.2509e+05 2.6165e+05 3.0182e+05 3.4573e+05 3.9354e+05 4.4539e+05 5.0142e+05 5.6178e+05 6.266e+05 6.9602e+05 7.7019e+05 8.4923e+05 9.333e+05
Columns 27 through 39
1.0225e+06 1.117e+06 1.2169e+06 1.3224e+06 1.4336e+06 1.5505e+06 1.6734e+06 1.8024e+06 1.9376e+06 2.0791e+06 2.2271e+06 2.3816e+06 2.5429e+06
Columns 40 through 52
2.7109e+06 2.886e+06 3.0681e+06 3.2574e+06 3.4541e+06 3.6582e+06 3.8698e+06 4.0892e+06 4.3163e+06 4.5514e+06 4.7946e+06 5.0459e+06 5.3055e+06
Columns 53 through 56
5.5735e+06 5.85e+06 6.1352e+06 6.4291e+06
The problem is NOT the plot. The problem is that somehow, you generated a garbage model.
ALWAYS look at what you got from a computation. Plotting garbage and expecting to magically see what you want to see is a good path to failure.
And since we have not been shown where those coefficients came from, how can we realistically help you?
Perhaps you wanted to do this:
mdl = fittype('power1')
mdl =
General model Power1:
mdl(a,b,x) = a*x^b
fittedmdl = fit(pressure',flow',mdl)
fittedmdl =
General model Power1:
fittedmdl(x) = a*x^b
Coefficients (with 95% confidence bounds):
a = 29.17 (23.95, 34.4)
b = 0.5049 (0.456, 0.5538)
f_exp = fittedmdl.a*p.^fittedmdl.b;
plot (pressure,flow,'o',p,f_par,p,f_exp,'--')
legend ('eperimental data','parabolic fit','exponential fit')
xlabel ('pressure psi') , ylabel ('flow gpm'),grid
That presumes the Curve fitting TB.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!