0

I have a function that returns class, for example:

xgrid = [1,2,3]
vals = [4,3,6]
f = @(k)griddedInterpolant(xgrid*k, vals)

Then I can get class member, which is interpolant in this case. Then I can use interpolant to get value at every point.

inter = f(3) % for example
inter(100) % returns value at point 100.

Is there a way, I can do this in one construction? For example:

f(3)(100) % will return me value of interpolant
  • No this isn't possible. You are trying to index into a variable or call a function and access its results without it being intermediately stored. See the duplicate for more details. P.S... it *is* possible, but it's very ugly. Just use intermediate variables. – rayryeng Oct 30 '15 at 17:27

1 Answers1

0

Such nested function calls are not allowed in matlab, you have to use a helper function to solve this.

paren = @(x, varargin) x(varargin{:});
f2=@(k,x)paren(f(k),x)
f2(3,100)
Daniel
  • 36,610
  • 3
  • 36
  • 69