I am facing some problem during calculation of Numerical Integration with two data set. For integration i am using simpsons 1/3 rule.
function I = Simpsons(f,a,b,n)
if numel(f)>1 % If the input provided is a vector
n=numel(f)-1; h=(b-a)/n;
I= h/3*(f(1)+2*sum(f(3:2:end-2))+4*sum(f(2:2:end))+f(end));
else
h=(b-a)/n; xi=a:h:b;
I= h/3*(f(xi(1))+2*sum(f(xi(3:2:end-2)))+4*sum(f(xi(2:2:end)))+f(xi(end)));
end
This code correctly calculates the integration.
Now the problem occurs during the calculation of multiplied values.
for example I have two functions f and g both are depending on same variable. the variables is in the same ranges. SO lower Limit and Upper Limit is same.
$\int_a^b \! f(x) *g(x) \, \mathrm{d} x.$
here the resolution of x is different. Means for f(x) we have 1000 data where as for g(x) we have 1700 data points. so element by element multiplication cant be done.
How to Solve this integration ..