trapz whe x is a matrix

11 ビュー (過去 30 日間)
Jose Costa
Jose Costa 2019 年 11 月 19 日
コメント済み: dpb 2019 年 11 月 22 日
I have a Y matrix size 2500x11 were each line corresponds to the 11 vales of curve points for trapezoidal integration.
the x values are not uniform and they vary so i have a second matrix for X size 2500x11.
I' tring to integrate using trapz (X,Y,2) but I get error "X must be a vector.".
How ca one use trapz with a matrix for x values? In octave it works.

採用された回答

dpb
dpb 2019 年 11 月 19 日
TMW only implemented variable X spacing for the full array, not by column (or row). Have to loop to do it...worthy of an enhancement request for the added functionality it would seem.
N=size(Y,1);
for i=1:N
Q(i)=trapz(X(:,i),Y(:,i));
end
  3 件のコメント
Jose Costa
Jose Costa 2019 年 11 月 22 日
sorry, 2500x11.
dpb
dpb 2019 年 11 月 22 日
MATLAB is not Octave! Converse is also true... :)
Feel free to submit the enhancement request...I'd suggest referencing this thread if do so.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by