Double integral with variable limit with integrand as an numerical array

조회 수: 11 (최근 30일)
Akshay Tiwari
Akshay Tiwari 2022년 11월 24일
답변: Walter Roberson 2022년 11월 24일
I have integrands as numerical vectors denoting probability density functions as shown in the following equation.
and are numerical vectors of equal size.
I want to double integrate them with a variable limit () on lower integral. In my knowledge, symbolic integrals (e.g. integral2) available in MATLAB don't take numerical vectors. On the other hand I don't know how to use trapz (used for integration of numerical vectors) when the limit is variable. I am showing one of the codes where I failed.
f1 = 1:100;
f2 = 1:100;
% Element wise multiplication of f1 and f2 to make them a single vector
F = f1.*f2;
I_in = @(t2) trapz(t2:100,F); % inner integral
I = trapz(60:100, I_in(t2));
Unrecognized function or variable 't2'.
It gives the following error:
Error using trapz
Dimension argument must be a positive integer scalar within indexing range.
Any help in this regards would be greatly appreciated.
  댓글 수: 2
Torsten
Torsten 2022년 11월 24일
According to your notation, f1 and f2 have to be matrices, not vectors because f1 = f1(t1,t2) and f2 = f2(t1,t2).
Akshay Tiwari
Akshay Tiwari 2022년 11월 24일
No, and are vectors. The integral equation is implying that and are integrated when can go from to , and can go from to .

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2022년 11월 24일
Use integral2(). The first set of bounds must be numeric, but the second set of bounds can be function handles.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by