Equation of two Matlab function files

46 Views Asked by At

I have two different Matlab function files which compute both a quantity with an integral by use of the trapezodial rule. Now, I would like to solve the following equation for $\lambda,a,b$:

$$quantity1(\lambda,a,b)=quantity2(\lambda,a,b)$$

Does anyone know a way to solve this by use of Matlab? So I'm looking for a function in Matlab that can solve the equation of two function files. Hopefully anyone can help me out!

1

There are 1 best solutions below

1
On

It's been a while since I used MATLAB, but it should be possible with the fnzeros function. Your equation is equivalent to $$\mathrm{quantity1}(\lambda,a,b)-\mathrm{quantity2}(\lambda,a,b) = 0 $$

Hence, define a function (with inputs $\lambda$, $a$, $b$) that is the difference between your two existing functions, and then use the fnzeros function to find the zeros.