find x points which makes a best fit to a curve
Show older comments
Hallo Matlab forum.
I need help to figure out how to reduce a curve described by 10.000 points to a curve described by less than 50 points and still have the best fit.

All my curves have the shape showen in the plot above, and as shown the problem is around the maximum and in the "tail" after.
I am currently reducing the amount of points by following two steps:
1: Remove point ii if the slope between point e(ii-1,1) to e(ii,1) is the same as the slope between point e(ii,1) to e(ii+1,1).
n = length(e) ;
for i = 1:n-2
ii = n-i ;
if abs((e(ii-1,2)-e(ii,2))/(e(ii-1,1)-e(ii,1)) - (e(ii,2)-e(ii+1,2))/(e(ii,1)-e(ii+1,1))) < 0.001
e(ii,:) = [];
end
end
2: Remove every 2nd row if there is still more than 50 rows left.
while length(e)>50
n = length(e) ;
dz = e(end-2,1) - e(end-1,1) ; % Stepsize.
for i = 2:2:n-15
ii = n-i ;
if (e(ii,1)-e(ii+1,1)) - dz < 0.001 && (e(ii-1,1)-e(ii,1)) - dz < 0.001
e(ii,:) = [];
end
end
end
What else can i do to improve the fitting of the curve with small amount of points?
Accepted Answer
More Answers (1)
per isakson
on 10 Dec 2013
0 votes
Categories
Find more on Fit Postprocessing 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!