MATLAB: How to substitute variables in a multivariable function while keeping some other parameters as variables

anonymousfunctionMATLABsubstitutesubstitution

How to substitute variables in a multivariable function while keeping some other parameters as variables?
I have a function with 3 parameters, y = f(a,b,c). I now have the numerical values for b = 1 and c = 2, how can I make it into a function of y = f(a)?

Best Answer

You can substitute the variables into the parameters and create a new anonymous function as shown in the example below:
 
>> f1 = @(a,b,c) sin(a) + exp(b) + c + 1;
>> f2 = @(x) f1(x, 1, 2);