find x points which makes a best fit to a curve
显示 更早的评论
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?
采纳的回答
更多回答(1 个)
per isakson
2013-12-10
0 个投票
类别
在 帮助中心 和 File Exchange 中查找有关 Fit Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
