필터 지우기
필터 지우기

Integral2 of a dot product

조회 수: 5 (최근 30일)
Neelima Dahal
Neelima Dahal 2018년 8월 10일
댓글: Walter Roberson 2018년 8월 20일
Below is what I have:
Z=@(x,y) x+1i*y;
T=@(x,y) ((sinh(pi/ha*(Z(x,y)-1i*ha/2))).^2);
E=@(x,y) conj(1i*pi*V/ha*1/(K_ka_p)*sqrt((TC-TA)./(T(x,y)-TA)));
E_conj=@(x,y) conj(E(x,y));
Int=@(x,y) dot(E(x,y),(E_conj(x,y)))
Interaction=integral2(Int,0,1,0,1);
When I run the code, I get the error "Integrand output size does not match the input size." I can get integral2 of all the functions leading up to Int. Just the Int function results in error. Anyone out there knows how to resolve this issue? Thank you!

답변 (1개)

Walter Roberson
Walter Roberson 2018년 8월 11일
"Integrand, specified as a function handle, defines the function to be integrated over the planar region xmin ≤ x ≤ xmax and ymin(x) ≤ y ≤ ymax(x). The function fun must accept two arrays of the same size and return an array of corresponding values. It must perform element-wise operations."
Your E(x,y) and E_conj(x,y) parts appear to handle that okay, but when you dot() those two arrays you get a single result instead of element-wise computation. Perhaps you should just be using .* instead of dot()
  댓글 수: 6
Neelima Dahal
Neelima Dahal 2018년 8월 20일
편집: Walter Roberson 2018년 8월 20일
I got it to work in the following manner -
Z1=@(x,y) x+1i*y;
T1=@(x,y) ((sinh(pi/ha1*(Z1(x,y)-1i*ha1/2))).^2);
E1=@(x,y) conj(1i*pi*V/ha1*1/(K_ka_p1)*sqrt((TC1-TA1)./(T1(x,y)-TA1)));
E_conj1=@(x,y) conj(E1(x,y));
Int1=@(x,y) (E_conj1(x,y).*(E_conj1(x,y)));
Intr=(integral2(Int1,xmin,xmax,ymin,ymax))
Walter Roberson
Walter Roberson 2018년 8월 20일
Int1=@(x,y) (E_conj1(x,y).*(E_conj1(x,y)));
It would look to me more efficient to use
Int1=@(x,y) E_conj1(x,y).^2;
But your original had E dot E_conj, so it is not clear to me that the new Int1 calculates what you had wanted to calculate.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by