Is possible solve a integral with a vector in the limitis?

1 回表示 (過去 30 日間)
eric rocha
eric rocha 2018 年 11 月 20 日
コメント済み: Star Strider 2018 年 11 月 20 日
%I am tring to make a fit where the xdata are in the limits of integral
%but this is not allowed
clear all
load C:\Users\Aluno\Desktop\rafael\novo\B100.txt
xdata = B100_(:,1);
ydata = B100_(:,2);
fun = @(x,xdata) x(1) + x(2).*integral( @(V) V , 0 , xdata);
x0 = [ 1, 2];
output = lsqcurvefit(fun,x0,xdata,ydata)
  2 件のコメント
Jan
Jan 2018 年 11 月 20 日
What is the mathematical meaning of an integral with a vector as limit? As long as it is not defined mathematically, you cannot expect that a standard function calculates it.
eric rocha
eric rocha 2018 年 11 月 20 日
For example, I am trying make a fit with the result of a implicit integral that only can be solved numericaly. (sorry about my bad gramma, I am a portuquese native speak and my english is not very good)

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2018 年 11 月 20 日
Yes.
Try this:
fun = @(x,xdata) x(1) + x(2).*arrayfun(@(xd)integral( @(V) V , 0 , xd),xdata);
It works either with or without the 'ArrayValued',1 name-value pair. The arrayfun function replaces a for loop, so each element of ‘xdata’ is evaluated as the upper limit of the integration in each iteration.
  2 件のコメント
eric rocha
eric rocha 2018 年 11 月 20 日
Really thanks.
Star Strider
Star Strider 2018 年 11 月 20 日
As always, my pleasure.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 11 月 20 日
In order to evaluate integral with multiple limits you will need to use arrayfun.
If you are concerned about efficiency you could sort xdata and integrate between consecutive endpoints and cumsum and then permute back to the original order .

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by