For loop relative to the quad function to apply integration, which is faster?

조회 수: 3 (최근 30일)
Mohamed
Mohamed 2012년 8월 28일
I have four integration for my problem, each is a surface integral. So basicaly, I have eight line integrals on theta and phi. The time processing is extremely slow when I am using eight nested for loops. I was wondering which is fatser to use 8 for nested loops or quad function?
If "quad" function is faster, do I then need to use "dblquad" function 4 nested times by creating four separate functions and using each one of them in a nested manner?
Thank you Regards Mohamed

답변 (1개)

Mike Hosea
Mike Hosea 2012년 8월 28일
I'm afraid I don't fully understand the question, but if you need to do a surface integral, use integral2. If you don't have R2012a, use quad2d. To use either of these functions, you supply an integrand function with 2 input arguments. The integrand function must be able to accept arrays (of the same size) for each of its input arguments and operate "element-wise", returning an array of corresponding function values. See "help integral2" or "help quad2d". There's more to know, but at this point I don't know what information to supply.
  댓글 수: 1
Mike Hosea
Mike Hosea 2012년 8월 28일
BTW, if you have a triple integral, there's integral3. There's no integral4 for 4-D problems, but you can nest like so integral(@(w)integral3(@(x,y,z)fun(x,y,z,w),blah,blah,blah),a,b,'ArrayValued',true).

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by