MATLAB: How to find the roots of implicit function using fzero function

fzero

I have written a function on MATLAB, say z=fun(x,y), here fun is an implicit function. But my question is how do I find x given y and z using "fzero" function on MATLAB? Can I write another function calling both fun and fzero?
I attempted to do this with the following code, which is another .m function file I wrote, but I got an error when I used fun2 in editor, why?
function y=fun2(y,z)
temp=fun(x,y)-z
y=fzero(@temp,0)
end

Best Answer

I’m not certain what you’re doing. The fzero function will only find the zero of a function of a single parameter. Since ‘y’ and ‘z’ are in your function’s workspace, you would have to define your fzero function call as:
temp = @(x) fun(x,y)-z;
x = fzero(temp,0);
NOTE — This is untested code.