Numerical Integration with variable limits MATLAB

member 428835
Hi PF!

Suppose I have two functions ##f(x),\,g(y)## that are numerically defined as vectors (i.e. ##g(y) = [0,1,4,9,16]:y = [0,1,2,3,4]## and say ##f(x) = [0,1,8,27,64]:x = [0,1,2,3,4]##) and am trying to compute $$\int_0^1 f(x) \int_x^1 g(y)\, dydx.$$

How would I do this in MATLAB? I could be in the wrong thread here, in which case I'm sorry!
 
f and g are defined only for discrete points. Without further definition, there is nothing to integrate.
 
mathman said:
f and g are defined only for discrete points. Without further definition, there is nothing to integrate.
Let's say ##g(x) = x^3## and ##f(y) = y^2##. Now can you help?
 
Rereading my post, that came off a little rude. I'm not trying to be. Just wanting to make sure I have addressed the issue you pointed out. :)
 
It might be better to ask questions about Matlab in the computers and programming section of the forum.

Ask how ##\sum_{k=1}^5 ( \ f(k) \sum_{j=k}^5 g(j)\ )## would be done.
 
  • Like
Likes   Reactions: member 428835
To properly answer this question we need to know how familiar you are with numerical integration and how familiar you are with matlab.

Think about what numerical integration is... you are basically summing up the f(x) values as you sweep the x axis. If you have discrete points this becomes easy, as you are already ready. With some MATLAB knowledge this is fairly easy.
 
The function cumsum() may help you to do this, but only if the x value increases by the same amount every time
Alternatively you may need to write your own function, if you have varying x values.
 
donpacino said:
To properly answer this question we need to know how familiar you are with numerical integration and how familiar you are with matlab.
I'd say I'm pretty familiar with both, but I know some people on here are way more advanced than me, so I'm unsure. I think I'm going to write my own double sum from Stephan Tashi's post. Thanks for your input!
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
3K
Replies
3
Views
4K
Replies
27
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
10K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K