MATLAB: Find and display intersections using fzero
functionsgraphintersectionsplot
I have two functions: f(x) = x.^2-1, f(g) = exp(x/5) in a linspace(-2,2). I need to indicate on the graph where f = g using the fzero function. Also I would like to keep it in a single m file.
Thanks
Best Answer
If f(x) = g(x) then f(x) - g(x) = 0. So we need to define h(x) = f(x) - g(x) and find where h(x) = 0. This is exactly what fzero is made for.
h = @(x) x.^2 - 1 - exp(x/5); % Creates a function handle for your function
Now let's plot and see if we can find a point close to where this function is zero.
Best Answer