MATLAB: Solve a nonlinear system

fsolvefzerononlinear

I'm solving the following as:
f = @(R01) 1/(1+R01) - .95;
R01 = fzero(f,0);
f = @(R02) 0.08/(1+R01) + 1.08/(1+R02)^2 - .99;
R02 = fzero(f,0);
How can I solve the system in one shot, can't make it work with fsolve.
Thanks
Oleg

Best Answer

Is this what you're trying to do?
f = @(x) [1/(1+x(1)) - .95; 0.08/(1+x(1)) + 1.08/(1+x(2))^2 - .99];
R = fsolve(f,[0 0]);
If so, you can't do it with fzero because it only accepts a function with a scalar input and scalar output.