I am new to Matlab. I am trying to solve a non-linear equation using this inbuilt Matlab function called fzero() but it's not giving me the results.
The main file goes like
A = 5;
B = 6;
C = 10;
eq = equation (A, B, C);
fzero(@(x)eq, 0);
The other function file is:
function eq = equation (A, B, C)
syms x;
eq = A*x.^2 + B*x + C*(asinh(x)) ;
When I run this code, I get the following error:
Undefined function 'isfinite' for input arguments of type 'sym'.
Error in fzero (line 308)
elseif ~isfinite(fx) || ~isreal(fx)
Error in main (line 7)
fzero(@(x)eq, 0);
Could someone help me with this?
If you are trying to solve the equation numerically, which is what fzero() does, you should do this:
The key difference is that you don't use symbols. fzero() can't handle them, I believe. You are right about the use of the anonymous function handle. :)