16 views (last 30 days)

Hello,

I am currently doing some experiments with a SLS/SLM machine in which I measure the width of the product of the experiment in relation to the speed that the laser is moving. For example:

Speed in mm/sec:

Speed = [0.1:0.1:1.3];

Measured width in mm:

Width = [3.46 2.45 2.22 2.00 1.20 1.10 1.09 1.00 0.75 0.65 0.62 0.55 0.42];

My problem is the following:

The data I presented above can be easily curve fitted into a 5-degree polyonim. However, the reality of the phenomenon I study indicates that at 0 mm/sec speed I will have 0 mm width and when the limit of the speed of the laser approaches 0, then the limit of the width will approach infinity. Also when the limit of the laser speed approaches infinity, then the limit of the width will approach zero.

How is it possible to contruct a curve fitting model to include these characteristics?

Thank you for your time in advance.

John D'Errico
on 26 May 2017

Edited: John D'Errico
on 26 May 2017

(Really, this is not even a question about MATLAB at all, but a general modeling question. And really, no more than common sense here.)

This is patently silly. You want some computer program to know in some magical way that your function has given behavior at zero and inf, and then provide an intelligent choice of model from infinitely many possible models, then fit it to your data.

Yet you say that for YOU to choose some model that has the desired shape would be too arbitrary?????

Sorry, but you need to provide some model, that has the desired intelligently chosen shape. A general polynomial is just silly here too, since it will never have the desired shape.

Note: even if you used a more general polynomial form, it won't have the desired behavior.

For example, this curve:

1.3182*Speed.^-0.43051 + -0.61613*Speed

fits your data quite well, and has a singularity at 0 as desired, you it fails to have the desired behavior at infinity. If you remove the linear term, the curve fit is poor.

Or, you could use this nonlinear form:

Width = 2.3596*(Speed + 0.74909).^-2.2344

which has the desired behavior at inf, but a singularity around x=-0.75.

Again, you need to provide some intelligent thought about the model.

For example:

plot(Speed,Width)

So, how could I transform the problem in a way that has a singularity at zero, yet also have the desired behavior at infinity? What simple transformation gives you what you what you are looking for?

semilogx(Speed,Width,'o-')

grid on

Gosh. A straight line fit in that domain would be as much as your data is worth. As well, it looks like an asymptote of zero at infinity seems wrong from these plots.

P1 = polyfit(log(Speed),Width,1)

P1 =

-1.1789 0.67756

So your model is effectively:

width = P1(1)*log(Speed) + P1(2)

Try it out.

plot(Speed,Width,'bo',Speed,P1(1)*log(Speed) + P1(2),'r-')

grid on

Ok, this does not have the desired behavior as Speed --> inf. But your data does not seem to support the idea that Width goes to zero at infinity. You can choose a different model of course. But you need to supply a model that makes sense, AND has the desired characteristics, AND can fit the data.

Computers should never be used to do your thinking for you. You will get garbage if you let that happen. Just apply common sense and basic mathematics.

Walter Roberson
on 26 May 2017

"If you have a phenomenon without any theoretical background, how can you visualize it accurately mathematically (with some certainty)?"

That is not possible.

Consider any finite set of data with N points finitely represented. Lagrange Interpolating Polynomials prove that you can exactly fit a polynomial of degree (N-1) to the finite data (exactly to within round-off error.)

Now take all of the distances between the X coordinates and their adjacent point. Convert the distances to rationals in lowest terms. Take the denominators and find the lowest common multiple; call it F. The fraction 1/F which is its reciprocal is guaranteed to divide all of the adjacent distances.

Now take the interpolating polynomial you constructed, and add to it sin((x-x0)*pi*F) where F is the denominator you constructed above. sin((x-x0)*Pi*F) is 0 at x0 and is 0 every 1/F to the next integer. The points are all multiples of F apart from x0, they are all integer multiples of pi further on from x0, so sin((x-x0)*Pi*F) will contribute 0 at each of the defined points. It will contribute something different from 0 at some points in-between -- points that you have no information about the location of because you have no theory to guide you as to where they are.

You have now constructed a polynomial that fits the known points perfectly, and you have also constructed a second expression that also fits the known points perfectly. You could construct any arbitrary number of further expressions as integer multiples of Pi*F. You can also create variations by multiplying the sin component by any arbitrary non-zero magnitude.

You now have an indefinite number of expressions all of which fit the data perfectly. Which do you choose?? Since you have no theory to guide you as to how the points relate, you cannot say that one of the expressions is "better" than the others.

There are other periodic functions you can construct that give you the same results as sin() for this matter, such as using cos with a phase bias, or using square waves that are 0 at the points of interest, or using triangle waves, or wavelets. You can also construct functions that are not entirely periodic but do pass through magnitude 0 at the points you need.

You could, for example, at an arbitrary number of other x coordinates and random y coordinates to the original points, as long as none of the ones added are the same x as the original. Langrange interpolating polynomials will fit that extended data just as perfectly as the original data, and this variation gets you a polynomial rather than a periodic function.

So there are many different ways to construct equations that perfectly fit the observed data, all different. Aleph-One different ways of constructing such equations. The probability that any one of those equations, selected randomly, is the "right" equation, is zero. But no computer program can tell any of them apart from any other without being told some theory (model) of what form the equation should take.

... And the data that you do have is probably not perfect anyhow. Optic systems have quantum noise even if all mechanical noise is ruled out.

This is all a quite different matter than one of determining appropriate coefficients given a model. If you know that the physical system has one of a few different possible forms, then you can try them all and find the best fit, and use the different forms to make predictions that you can then test to isolate possibilities.

Opportunities for recent engineering grads.

Apply TodayFind the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 5 Comments

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/341968-curve-fitting-for-non-continuous-data-with-infinity#comment_456788

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/341968-curve-fitting-for-non-continuous-data-with-infinity#comment_456788

I am confused by your question.

I've attached a plot of your data. The trend seems to be

(But you also said, "at 0 mm/sec speed I will have 0 mm width", which doesn't seem right.)

Why would you want to fit a 5th-order polynomial to that? That would be zero at Speed=0, and go to infinity at large speed, right? Why not fit an exponential decay, for example? What do you know about the underlying functional form that would be expected from the physical phenomenon?

Thatis what should guide your choice of fit.## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/341968-curve-fitting-for-non-continuous-data-with-infinity#comment_456790

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/341968-curve-fitting-for-non-continuous-data-with-infinity#comment_456790

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/341968-curve-fitting-for-non-continuous-data-with-infinity#comment_456791

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/341968-curve-fitting-for-non-continuous-data-with-infinity#comment_456791

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/341968-curve-fitting-for-non-continuous-data-with-infinity#comment_456804

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/341968-curve-fitting-for-non-continuous-data-with-infinity#comment_456804

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/341968-curve-fitting-for-non-continuous-data-with-infinity#comment_456805

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/341968-curve-fitting-for-non-continuous-data-with-infinity#comment_456805

Sign in to comment.