From: fillmore koller on 17 Jun 2010 12:08 Hi the quad/quadgk numerical integration function needs to accept a vector arguement. i have to perform the integration for every entry in a matrix. Is there way to do this line by line instead of element by element? eg. the function is: function f = myFunction(r, a) f = exp(r*a.^2); % m the matrix associated with a plane with m=zeros(yn,xn) x =linspace(-10,10,xn) y =linspace(-10,10,yn) for i=1:yn r = sqrt(x.^2+y(i)^2) m(i,:) = quadgk(@(a) myFunction(r,a),0,1 ) end; now this works if "r" is constand, is there a way that it works with "r" beeing a vector?
From: John D'Errico on 17 Jun 2010 12:25 "fillmore koller" <pas.koller(a)gmx.de> wrote in message <hvdh94$gs$1(a)fred.mathworks.com>... > Hi > > the quad/quadgk numerical integration function needs to accept a vector arguement. > i have to perform the integration for every entry in a matrix. Is there way to do this line by line instead of element by element? > > eg. the function is: > > function f = myFunction(r, a) > f = exp(r*a.^2); > > % m the matrix associated with a plane with > m=zeros(yn,xn) > x =linspace(-10,10,xn) > y =linspace(-10,10,yn) > > for i=1:yn > r = sqrt(x.^2+y(i)^2) > m(i,:) = quadgk(@(a) myFunction(r,a),0,1 ) > end; > > now this works if "r" is constand, is there a way that it works with "r" beeing a vector? help quadv john
|
Pages: 1 Prev: How to check if a string matches any string in a matrix C Next: interpolation |