"lucy" <
[email protected]> wrote in message
news:cg3ldl$83a$
[email protected]..
> Hi all,
>
> I have a curve data which is very zigzag and toothshaped and not very
> smooth.
>
> The curve data is obtained when a user is dragging mouse over the figure
> window...
>
> So basically this is the trace of the mouse movement...
>
> But due to hand-shaky and mouse mechanical problem this curve is not
smooth
> at all...
>
> This curve data is now in two vectors:
>
> How can I smooth this curve?
>
> Thanks a lot.
>
> (Please see the attached image to see the screenshot of the image... I am
> also wondering how does those curve smooth in Photoshop and Microsoft make
> out? I know averaging filter such as 0.5*[1 1], or 0.3333*[1 1 1] will do
> some averaging... but how to make those arcs smooth yet round?)
>
> X=
>
> 54 58 62 66 70 74 78 82 86 90 94 98 102 106 110 114 118 122 126 130 134
138
> 142 146 150 154 158 162 166 170 174 178 182 186 190 194
>
> Y=
>
> 0.79478 0.63915 0.53504 0.64711 0.33612 0.78045 0.58196 0.64732 0.59954
> 0.56147 0.55928 0.77946 0.64417 0.77246 0.54446 0.68093 0.69689 0.53509
> 0.53509 0.82718 0.53844 0.68799 0.55039 0.56318 0.85827 0.65704 0.61883
> 0.70684 0.79271 0.71719 0.72592 0.80416 0.81989 0.83584 0.84005 0.77577
You have some decisions to make up front:
1) are the end points to be considered "perfect" or to be treated as all the
other data points?
2) do you want first order / straight line? or do you want second order /
curve? or do you want something with inflection points?
Assuming you want a second order curve, you might fit the data in a least
squares sense to a second-order polynomial:
ax^2 + bx + c
This is easy to do with Excel - just compute the error squared at each point
and use the Tools / Solver to minimize the sum of all errors.
If you want the ends to nearly match the data, then weight the error heavily
at the ends by multiplying the error at the ends only by 10 or 50 or......
If you want the ends to exactly match the data, then weight the error very
heavily at the ends - this effectively removes two of the three degrees of
freedom that you have - so you will be only changing the curve.
Fred