Integration of a function with respect to a dummy variable

5 ビュー (過去 30 日間)
Nikhil Yewale
Nikhil Yewale 2020 年 5 月 6 日
編集済み: Nikhil Yewale 2020 年 5 月 6 日
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 Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by