MATLAB: Using quad

MATLABquad

A question is: there is function f(t,a,b) and g(t) where a, b are known variables. Find the area between the curves. I just want to know if I am doing it right, this was one of the old exam questions that could be again.
Is it
Area=quad(@f,a,b)-quad(@g,a,b)
or
fzero(@f(t)-@g(t))=c,d
Area=quad(@f,c,d)-quad(@g,c,d)
I am not getting this at all…
please can someone explain it to me but in a steps so I can understand it
Thank you

Best Answer

None of the above.
f(t,a,b) where a and b are constants, is effectively a function in a single variable, t.
g(t) is already a function in a single variable, t.
In order to find the area between the curves, you would need to know the range of t that you were working over. That range is not given anywhere, and there is no reason to expect it to be related to "a" or "b".
The variables "c" and "d" do not appear in the problem definition, so the two answers that involve "c" and "d" must be presumed to be "noise" answers designed to distract.
The correct answer would involve
Area = quad(@(t) f(t,a,b), P, Q) - quad(@g, P, Q)
where P and Q are the unknown limits.
One cannot assume that the limits P and Q should be -inf and +inf, as quad() cannot be used with infinite limits. quadgk() can, though, be given infinite limits; if that is what one assumed then it would be
Area = quadgk(@(t) f(t,a,b) - g(t), -inf, inf)
But of course making an assumption on an exam is a Bad Thing.