Determine differentiability of a x and y dataset
Show older comments
Hello everybody,
I have a dataset (x old, y old). Now I do some math on it and get a new dataset (x new, y new). To check whether my calculations are correct, the curve of the new datset must be differentiable.
Do you have any ideas, how I could do this "check"?
Thank you
Cheers
Christian
1 Comment
Answers (1)
Guillaume
on 8 Mar 2017
The concept of diferrentiable does not mean much for a discretised function. By definition dy/dx always exists when you have a vector of x and y values, unless one of y or x is infinite or NaN.
So really the only thing you could test is
assert(all(isfinite(xnew)) & all(isfinite(ynew)))
7 Comments
Christian
on 8 Mar 2017
Well, if all the points are finite then your discretised function is differentiable.
For a discreet set of points, the derivative is equivalent to y(i+1)-y(i), that is the diff function in matlab. So for dicreet points, being differentiable simply means that you can calculate diff(y)./diff(x)
Note: I am assuming there's no duplicate x, since otherwise diff(x) is 0 and in this case, the function is indeed not differentiable.
Christian
on 8 Mar 2017
Guillaume
on 8 Mar 2017
Well,
all(diff(x) > 0) | all(diff(x) < 0)
will tell you if all the x values are strictly monotonically increasing or decreasing.
I'm not sure what you mean by perfect sharp bend.
Christian
on 8 Mar 2017
Jan
on 8 Mar 2017
Guillaume is right: For a discretized function, the term "differentiable" has no meaning. A line like x=[1,2,3], y=[1,2,100] might or might not represent a differentiable function, because even a smooth function can contain a huge derivative in one point. There is also no to "proove" if sin(1/x) is differentiable in x=0 if all you have is a finite number of its values.
All you can decide based on a set of data points is if the difference between neighboring points exceeds a certain limit or not. But this does not mean differentiablility.
Christian
on 8 Mar 2017
Categories
Find more on Variables 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!
