Integrating a Complicated Function in MATLAB with Triplequad

In summary, the user is having trouble using the triplequad function in MATLAB due to a complicated function and wants to convert it to a summation. They have a 12x12 symbolic matrix that needs to be simplified and integrated over, but MATLAB cannot find the 12 eigenvalues. The user is seeking guidance on how to properly convert their problem into a format that can be solved with MATLAB.
  • #1
quin
50
0
Dear users
I want to get a triple integral from "X,y,z" in MATLAB like this: triplequad(f,0,1,0,1,0,1) but because my "f" is very very complicated function of x,y,z , it can not do it, so I want to convert my integral to a summation and istead of my integral limits I want to make sum in a way that each of x,y,z vary from 0 to 1 by steps of 0.01
So would you mind tell me what should I write in matlab?

thanks
 
Physics news on Phys.org
  • #3
thank you but my MATLAB is 2011
let me explain you that infact why I want to change my triplequad to sigma. (summation)
I have a 12*12 symbolic matrix in terms of x,y,z ,I must first find its eigenvalues and when I found 12 terms, I must do some aljebraic operations on them and mix them into one sentence and after that Integrate over that finall sentence in terms x y z
but the 12*12 matrix is so complicated and MATLAB couldn't find the 12 eigenvalues. so I want to put my matrix and all of aljabraic operations in 3 " "for" loops" and during loops I sum that final sentence instead of integrating
In this way the 12*12 matrix will be numeric and can find its eigenvalues but I won't have any x , y,z which I must integrate over them instead with those for loops I must the expression and cannot integrate.
I hope that yoU understand what I meant
thank you
 
  • #4
This really sounds like a project that you'll have to research and program yourself into matlab. I looked up MATLAB limits and it should be able to handle a 12x12 matrix.

http://www.mathworks.com/support/solutions/en/data/1-IHYHFZ/index.html

Perhaps if you break things up so the matrix isn't so complicated.

If this is a project we can only help with hints, we can't do the work for you.

By sentence I assume you mean equation, right?

Perhaps if you describe your problem in terms of discreet steps instead in paragraph form. Someone will be better able to help. What you've said so far is very generic and hard to figure out what you're trying to accomplish.
 
Last edited:
  • #5
for your question. It sounds like you are trying to integrate a very complicated function using triplequad in MATLAB, but are having trouble due to the complexity of the function. In this case, it may be helpful to break down the integral into smaller parts and use a summation instead. This can be done by dividing the range of integration (0 to 1 in your case) into smaller intervals (0.01 in your example) and using a for loop to calculate the integral for each interval. You can then sum up the results from each interval to get an approximate value for the integral. The code for this approach would depend on the specific function you are integrating, but it would involve using a for loop and a sum function in MATLAB. I hope this helps!
 

1. How do I use the triplequad function in MATLAB?

The triplequad function in MATLAB is used to numerically integrate a complicated function with three variables over a rectangular region. To use this function, you need to specify the function to be integrated, the limits of integration for each variable, and any additional parameters necessary for the function. The syntax for using triplequad is "triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax)".

2. What types of functions can be integrated using triplequad in MATLAB?

Triplequad can be used to integrate any function with three variables over a rectangular region. This includes functions with single or multiple integrands, as well as functions with a mix of symbolic expressions and numeric values. However, the function must be well-behaved and smooth within the specified limits of integration.

3. How accurate is the integration performed by triplequad in MATLAB?

The accuracy of the integration performed by triplequad in MATLAB depends on the function being integrated and the specified tolerances. By default, triplequad uses a relative tolerance of 1e-6 and an absolute tolerance of 1e-10. These tolerances can be adjusted by including additional parameters in the function call. Generally, the accuracy of the integration can be improved by decreasing the tolerances, but this will also increase the computation time.

4. Can I use triplequad to integrate a function over a non-rectangular region in MATLAB?

No, triplequad in MATLAB can only be used to integrate a function over a rectangular region. If you need to integrate over a non-rectangular region, you can either transform the function and limits of integration to a rectangular region or use a different integration function in MATLAB such as quad2d or integral2.

5. How can I optimize the performance of triplequad in MATLAB?

To optimize the performance of triplequad in MATLAB, you can try adjusting the tolerances, using vectorized functions instead of symbolic expressions, or breaking the integration into smaller regions and then summing the results. It may also help to preallocate memory for the output to avoid unnecessary reallocations during the integration process.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
999
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
Replies
10
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
Back
Top