Double Integration. Function handle use

조회 수: 1 (최근 30일)
Zaharaddeen Hussaini
Zaharaddeen Hussaini 2018년 6월 5일
댓글: Zaharaddeen Hussaini 2018년 6월 6일
I have been trying hard to get to represent the following equation on matlab.
int_c = 1./((2.*pi.*sigma_tot.^2));
fun = @(lx,ly, sigtot) exp ( - ((lx.^2 + ly.^2)./(2*sigtot.^2 )));
lxx = 2 * RR;
lxx_min = -lxx./2;
lxx_max = lxx./2;
lyy_min = @(gamma)(-(RH.* cos(gamma))./2);
lyy_max = @(gamma)((RH.* cos(gamma))./2);
int_i = arrayfun(@(sigtot) integral2( @(xi,yi) fun(xi,yi,sigtot),lxx_min,lxx_max,lyy_min,lyy_max), sigma_tot);
This is what I have so far. Please bear in mind that the following equation was executed inside a loop. sigma_tot and gamma changes with every increasing loop count.
It does provide me with results but my main question is why does lyy_min and lyy_max have to have the function. Without it I will get an error. The true definition is supposed to be
lyy_min =(-(RH.* cos(gamma))./2);
lyy_max = ((RH.* cos(gamma))./2);
However, the code would not run that way. So can anyone pls tell me if what I represented make sense.
Thanks
  댓글 수: 6
John D'Errico
John D'Errico 2018년 6월 6일
I think what you misunderstand is that if gamma is fixed at some value, then it is fixed at the current value in your workspace. But the limits are functions of gamma. You need to write it as a function, else it will not be used as a function.
Zaharaddeen Hussaini
Zaharaddeen Hussaini 2018년 6월 6일
Yes they are. Okay. Thanks for the further clarification.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by