Reputation: 476
Suppose I have a function which is extremely time consuming to evaluate and I want to generate an interpolated version of it using as few function evaluation as possible. Is there a built in function in Matlab to do that (something like FunctionInterpolation from Mathematica) ?
The procedure is not very difficult and I am aware of freely available implementations (in other languages) like http://scipy-central.org/item/53/1/adaptive-sampling-of-1d-functions but considering that matlab has build in triangular mesh refinement, I think there might be also something like this to be used in one dimension.
Upvotes: 2
Views: 987
Reputation: 2509
You may use fplot with two output arguments, as
[X,Y] = fplot(fun,limits,...)
described in http://www.mathworks.fr/fr/help/matlab/ref/fplot.html
for instance
fun = @(x) 1./(1+x.^2)
[X,Y] = fplot(fun,[-10, 10])
Upvotes: 1