MATLAB: Create a function from another function with less parameters

function callspecify less parameters

I have a function, let's call it "myFunc". myFunc accepts two parameters, x and y. I want to create a new function "myFunc2", based on myFunc, with one parameter set to a certain value. (e.g x=1)
My final goal is to be able to call the function fzero, passing Myfunc2, that will be function of y only.
Is it possible? I also accept different solutions for achieving this. Thanks in advance

Best Answer

You can use an anonymous function.
addMe = @plus; % the plus function (equivalent of the + operator) accepts two inputs
addOne = @(x) addMe(x, 1); % accepts one input x and returns x+1
addMe(2, 3) % returns 5
addOne(2) % returns 3