How can I use Matlab for numerical integration?

In summary, there is a problem with integrating a vector with an unknown function and plotting the result. The goal is to plot a cosine function, but a sine curve is given and the exact plot is needed. The solution was found by using the gradient and cumtrapz functions.
  • #1
wildman
31
4
I figured it out. Thanks!
 
Last edited:
Physics news on Phys.org
  • #2
i want to integrate a vector(which function is unknown) and plot the result.suppose a sin curve is given(but i dint know it).which integration will be cosine.so i want to see the exact plot.how can i do it?
 
  • #3
tauhid035 said:
i want to integrate a vector(which function is unknown) and plot the result.suppose a sin curve is given(but i dint know it).which integration will be cosine.so i want to see the exact plot.how can i do it?

I've got the same question. Any help would be appreciated.
thanks
 
  • #4
dunno if anyone is still looking at this thread but I found this site really helpful
http://www.tufts.edu/~rwhite07/Matlab.html"

the gradient and cumtrapz functions took care of it.
 
Last edited by a moderator:

What is Matlab Numerical Integration?

Matlab Numerical Integration is a method for approximating the value of a definite integral using numerical algorithms instead of solving it analytically. It is a common technique used in scientific and engineering applications.

How do I perform numerical integration in Matlab?

To perform numerical integration in Matlab, you can use the built-in function "integral" or "trapz". The "integral" function uses adaptive quadrature methods to approximate the integral while "trapz" uses the trapezoidal rule. Both functions require the input of a function and the limits of integration.

What is the difference between "integral" and "trapz" in Matlab?

The main difference between "integral" and "trapz" in Matlab is the method they use to approximate the integral. The "integral" function uses adaptive quadrature methods, which can provide more accurate results for complex functions. The "trapz" function uses the trapezoidal rule, which is simpler but may not be as accurate for certain functions.

How can I improve the accuracy of my numerical integration in Matlab?

There are a few ways to improve the accuracy of numerical integration in Matlab. One way is to increase the number of integration points or decrease the tolerance level in the "integral" function. Another way is to use a different integration method, such as Simpson's rule or Gaussian quadrature, instead of the default method. Additionally, you can use a more accurate function to represent your original function, if possible.

Can Matlab perform numerical integration for multidimensional integrals?

Yes, Matlab can perform numerical integration for multidimensional integrals using the "integral2" and "integral3" functions. "integral2" is used for double integrals while "integral3" is used for triple integrals. These functions require the input of a function and the limits of integration for each variable.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
27
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
22
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
819
Back
Top