Evaluating multivariate functions with some arguments fixed
I have an anonymous multivariate function. Is it possible to f开发者_如何学Goind the value of the function by fixing one of the values?
Here is what I would like to happen:
>> f = @(a, b) a + b;
>> f(1, b)
ans =
1 + b
I understand that the input I gave above is syntactically invalid, since variables must contain values. Is there a way I can accomplish this through another Matlab tool?
Thanks.
There are two ways you can accomplish this. Either, you get the symbolic toolbox, and declare b
as a symbolic variable before evaluating f
, or you create a new anonymous function like this:
g = @(b)f(1,b);
精彩评论