Smoothing the plots with points
1 view (last 30 days)
Show older comments
x1 = [0.05, 0.101, 0.201, 0.401, 0.797, 1.597, 3.196, 6.39, 10.01];
y1 = [0.053, 0.832, 2.744, 3.737, 3.775, 3.823, 3.9, 4.039, 4.207];
x2 = [0.049, 0.097, 0.2, 0.403, 0.739, 1.596, 3.201, 6.39, 10];
y2 = [0.113, 0.797, 6.096, 7.271, 7.426, 7.603, 7.894, 8.266, 8.666];
x3 = [0.05, 0.099, 0.201, 0.402, 0.804, 1.6, 3.219, 6.38, 10];
y3 = [0.25, 1.595, 7.889, 11.403, 12.502, 12.7, 13.54, 14.672, 15.6];
How to smooth those? Also, I want to limit the x axis from 0 to 10.
Answers (1)
KSSV
on 28 Nov 2020
Try fitting a Bezier Curve: I have referred this link: https://in.mathworks.com/matlabcentral/fileexchange/33828-generalised-bezier-curve-matlab-code . Please note that code can be optimized.
x1 = [0.05, 0.101, 0.201, 0.401, 0.797, 1.597, 3.196, 6.39, 10.01];
y1 = [0.053, 0.832, 2.744, 3.737, 3.775, 3.823, 3.9, 4.039, 4.207];
% From here take from the link
p = [x1' y1'] ;
n = size(p,1) ;
n1 = n-1 ;
sigma = zeros(1,n1+1) ;
for i=0:1:n1
sigma(i+1)=factorial(n1)/(factorial(i)*factorial(n1-i)); % for calculating (x!/(y!(x-y)!)) values
end
l=[];
UB=[];
for u=0:0.002:1
for d=1:n
UB(d)=sigma(d)*((1-u)^(n-d))*(u^(d-1));
end
l=cat(1,l,UB); %catenation
end
P=l*p;
figure
hold on
plot(p(:,1),p(:,2),'b')
plot(P(:,1),P(:,2),'r')
legend("Original","BeizerCurve")
2 Comments
See Also
Categories
Find more on 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!