smoothen curve plotted using discrete points
3 views (last 30 days)
Show older comments
Sujay Bharadwaj
on 8 Jan 2022
Commented: Mathieu NOE
on 12 Jan 2022
flowrate = [ 0 93 100 120 140 160 172 180 200 220 232 ] ;
head = [ 9.51 8.76 8.68 8.41 8.01 7.45 7.03 6.70 5.73 4.49 3.61 ] ;
cv20 = [ 0.8 1.1 2.2 4.1 6.6 9.9 13.9 18.6 24.1 30.3 37.2] ;
cv20new = smooth(cv20);
cv30 = [ 0.8 1 1.5 2.4 3.7 5.3 7.3 9.6 12.3 15.3 18.7 ] ;
cv30new = smooth(cv30);
cv40 = [ 0.8 0.9 1.3 1.8 2.7 3.7 5 6.4 8.2 10.1 12.3 ] ;
cv40new = smooth(cv40);
cv50 = [ 0.8 0.9 1.1 1.6 2.2 2.9 3.9 5 6.3 7.7 9.3 ] ;
cv50new = smooth(cv50);
cv60 = [ 0.8 0.8 1.1 1.4 1.9 2.5 3.3 4.2 5.2 6.4 7.7 ] ;
cv60new = smooth(cv60);
cv70 = [ 0.8 0.8 1 1.3 1.8 2.3 2.9 3.7 4.6 5.6 6.7] ;
cv70new = smooth(cv70);
cv80 = [ 0.8 0.8 1 1.3 1.7 2.1 2.7 3.4 4.2 5.1 6.1 ] ;
cv80new = smooth(cv80);
plot(flowrate,head)
title('Pump Performance Curves Estimates')
hold on
plot(flowrate,cv20new)
hold on
plot(flowrate,cv30new)
hold on
plot(flowrate,cv40new)
hold on
plot(flowrate,cv50new)
hold on
plot(flowrate,cv60new)
hold on
plot(flowrate,cv70new)
hold on
plot(flowrate,cv80new)
hold off
ylim([0.0 10.0])
i want my curve to be smoothened into a parabola like the below graph:
The curves for cv20,cv30 .. are not smoothening even after i used the smooth curve command.
0 Comments
Accepted Answer
Mathieu NOE
on 8 Jan 2022
hello
this would be my suggestion - others methods I tried have not been successfull
flowrate = [ 0 93 100 120 140 160 172 180 200 220 232 ] ;
head = [ 9.51 8.76 8.68 8.41 8.01 7.45 7.03 6.70 5.73 4.49 3.61 ] ;
cv20 = [ 0.8 1.1 2.2 4.1 6.6 9.9 13.9 18.6 24.1 30.3 37.2] ;
cv30 = [ 0.8 1 1.5 2.4 3.7 5.3 7.3 9.6 12.3 15.3 18.7 ] ;
cv40 = [ 0.8 0.9 1.3 1.8 2.7 3.7 5 6.4 8.2 10.1 12.3 ] ;
cv50 = [ 0.8 0.9 1.1 1.6 2.2 2.9 3.9 5 6.3 7.7 9.3 ] ;
cv60 = [ 0.8 0.8 1.1 1.4 1.9 2.5 3.3 4.2 5.2 6.4 7.7 ] ;
cv70 = [ 0.8 0.8 1 1.3 1.8 2.3 2.9 3.7 4.6 5.6 6.7] ;
cv80 = [ 0.8 0.8 1 1.3 1.7 2.1 2.7 3.4 4.2 5.1 6.1 ] ;
% plot
figure(1)
plot(flowrate,head,flowrate,cv20,flowrate,cv30,...
flowrate,cv40,flowrate,cv50,flowrate,cv60,...
flowrate,cv70,flowrate,cv80);
title('Pump Performance Curves Estimates')
ylim([0.0 10.0])
% plot
flowrate2 = linspace(min(flowrate),max(flowrate),100);
[cv20new] = my_opti_fminsearch(flowrate,cv20,flowrate2);
[cv20new] = my_opti_fminsearch(flowrate,cv20,flowrate2);
[cv30new] = my_opti_fminsearch(flowrate,cv30,flowrate2);
[cv40new] = my_opti_fminsearch(flowrate,cv40,flowrate2);
[cv50new] = my_opti_fminsearch(flowrate,cv50,flowrate2);
[cv60new] = my_opti_fminsearch(flowrate,cv60,flowrate2);
[cv70new] = my_opti_fminsearch(flowrate,cv70,flowrate2);
[cv80new] = my_opti_fminsearch(flowrate,cv80,flowrate2);
figure(2)
plot(flowrate,head,flowrate2,cv20new,flowrate2,cv30new,...
flowrate2,cv40new,flowrate2,cv50new,flowrate2,cv60new,...
flowrate2,cv70new,flowrate2,cv80new);
title('Pump Performance Curves Estimates')
ylim([0.0 10.0])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [cvnew] = my_opti_fminsearch(flowrate,cv,flowrate2)
cv = interp1(flowrate,cv,flowrate2);
% fminsearch method
x = flowrate2;
a = cv(1);
f = @(b,x) a + b.*(x.^2);
b_init = (cv(end) - a)./(flowrate(end).^2);
obj_fun = @(params) norm(f(params(1),flowrate2)-cv);
sol = fminsearch(obj_fun, [b_init]);
b_sol = sol(1);
cvnew = f(b_sol, flowrate2);
end
2 Comments
Mathieu NOE
on 12 Jan 2022
here you want all curves to be a perfect parabola , so none of the "smoothing" functions can do an exact parabola
the trick is indeed to fit a parabola equation to your data with the constant term always the same (so all curves have same origin)
all the best
More Answers (0)
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!