Transpose for double integral
Show older comments
Hello! I'm trying to calculate a double itnegral in MATLAB, and I got help from another person on how to do. This is the code I got from them:
n=1000; m=1000;
a=0; b=1; c=-pi/2; d=pi/2;
f=@(x,y)y.*sin(y+x.*y);
x=linspace(a,b,n+1);
y=linspace(c,d,m+1);
h=(b-a)/n;
k=(d-c)/m;
qv = sum(sum(h.*k.*f(x(1:n)',y(1:m))))
this formula calculates the integral as rectangles. But my question is why we use the transpose? Using the transpose gives the correct answer, but I really don't understand why. I would, of course, ask the person who gave me the code if I could, but unfortunately I can't, and therefor I'm hoping that someone here can help me!:)
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!