Integration of a function with respect to a dummy variable

10 次查看(过去 30 天)
How to evaluate the integral ?
f(x) is integrated over a dummy variable z. Please note that x ((x(i) >= 0 or x(i) < 0)) is an array of n x 1 , and f(x) is a corresponding array of n x 1. I do not have the closed form expression for f(x), nor is curve fitting an option to approximate the data as an expression. How do I find corresponding vector A.
Kindly direct me to appropriate approach to solve this issue.

采纳的回答

Nikhil Yewale
Nikhil Yewale 2020-5-6
编辑:Nikhil Yewale 2020-5-6
Hello
The issue is resolved by discussion with some friends
% say we are integrating a data resembling a parabola
x = -2:0.01:1;
y = x.^2;
% say you wanted to integrate from x = -2 to x = 0..
% (lower limit x = -2 is variable..may use a loop over x as per user's req.)
index = find(x == 0);
I = cumtrapz(x(1:index),y(1:index));
% any ' i'th ' element in 'I' denotes integration from x = -2 to x = x(i)
-I(end) % this should give integration of x.^2 from -2 to 0

更多回答(2 个)

Hiro Yoshino
Hiro Yoshino 2020-5-6
Why don't you think about using Symblic Math Toolbox?
You can manipulate your equation as you wish.
  1 个评论
Nikhil Yewale
Nikhil Yewale 2020-5-6
Hello Sir, Thanks for the prompt reply
Symbolic toolbox is useful, however I do not have an expression for the function. I just have set of two arrays,
say x = [-0.5 -0.2 -0.1 -0.05 0 0.1 0.3 0.7] and so on
and I have corresponding array , say f = [-0.9 -0.5 0.4 0.3 0 -0.3 -0.5 0.5]
Using these two arrays I wish to find the integral , where you can imagine lower limit being set to 0, and upper limit being varied with each element of x(i).
This is like cumulative integral with a minor detail that lower limit is always set to 0.

请先登录,再进行评论。


Hiro Yoshino
Hiro Yoshino 2020-5-6
f = [-0.9 -0.5 0.4 0.3 0 -0.3 -0.5 0.5]
let me assume z to be:
z = [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0]
and
then
If you prefer continous manner, you should either approximate f as a function or interpolate the discrete numbers.
  1 个评论
Nikhil Yewale
Nikhil Yewale 2020-5-6
Thank you, Sir for your prompt reply,
I did get the idea that you were conveying from cumtrapz command and the issue is resolved.

请先登录,再进行评论。

类别

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