Is possible solve a integral with a vector in the limitis?
1 回表示 (過去 30 日間)
古いコメントを表示
%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
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.
採用された回答
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 件のコメント
その他の回答 (1 件)
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 .
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Numerical Integration and Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!