How to create a linearly interpolated symbolic function from data?
9 views (last 30 days)
Show older comments
I have measurements that can be described with unknown (and probably complicated) functions. I need symbolic functions that return the linear interpolated numbers between any two measurement points for any given time so I can define the Laplace-transforms of these functions. How can this be done?
2 Comments
Answers (1)
Walter Roberson
on 4 Apr 2016
Let x be the timepoints and y be the associated data values. Then for any time t between x(J) and x(J+1)
heaviside(t - x(J)) * heaviside(x(J+1) - t) * (y(J) + (t-x(J))/(x(J+1)-x(J)) * (y(J+1)-y(J))
so sum those formula over J = 1 to length(x)-1
I might have messed up the code slightly, as I simply wrote it out. It is the standard "origin plus a ratio of the change in value" calculation, together with a pair of heaviside that will only multiply to non-zero when the value is within the range.
Caution: you need to adjust this to take into account the value associated with heaviside(0), which there is no standard value for. Sometimes you want heaviside(0) to be 0, sometimes you want it to be 1, and it is not uncommon to see it defined as 1/2 . If it is defined as 0, then you need to use a dirac delta to add in the value at every boundary. If it is 1/2 then you need to use a dirac delta to add in half of the value at each boundary.
2 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!