By file do you mean that a separate M-file that defines the function to be integrated? That's the old-fashioned way to use quad
and the quadrature integration functions anyways. You shouldn't be passing in strings but rather function handles. Assuming that x
is the integration variable, you can use this:
KrInitialIntegratedPart = quad(@(x)sin(x)*exp(-AInitial/aInitial)*db, 0, fe);
The parameters AInitial
, aInitial
, and db
will be determined by their current value in the code. (Also, you don't need to use so many parentheses – it makes reading the code harder.)
If you do write your integration function in a separate M-file or a sub-function, you should still use function handles. In that case, you can call the function and pass in the parameters by creating an anonymous function like this:
KrInitialIntegratedPart = quad(@(x)MyFunName(x, AInitial, aInitial,db), 0, fe);
Depending on the version of Matlab you're using, you might try integral
instead (or quadgk
if you don't have that).