How can I make double integration

syms x;
syms r;
for n=1:10
for i=2:t
f1(i,n) = h * (Sast(i-1,n) + r* Y(i,n) - x) * 1 / (v(i,n)^(1/2) * sig(n) * (2 * pi)^(1/2)) * exp((-(x-m(i,n))^2) / (2 * v(i,n) * sig(n)^2)) * unifpdf(r,A(fv),B(fv));
f2(i,n) = -p * (Sast(i-1,n) + r * Y(i,n) - x) * 1 / (v(i,n)^(1/2) * sig(n) * (2 * pi)^(1/2)) * exp((-(x-m(i,n))^2) / (2 * v(i,n) * sig(n)^2)) * unifpdf(r,A(fv),B(fv));
z(i,n)=f1(i,n)+f2(i,n)
C2_1(i,n)=dblquad(z(i,n),inf,Sast(i-1,n),-inf,Sast(i-1,n))
%C2_1(i,n) = int(int(f1(i,n), x, inf, Sast(i-1,n) + r(i,n,fv)*Y(i,n)), y, inf, Sast(i-1,n) + r(i,n,fv)*Y(i,n)) + int(int(f2(i,n), x, Sast(i-1,n) + r(i,n,fv)*Y(i,n), -inf), y, inf, -inf);
%C2_1(i,n) = dblquad(f1(i,n), inf, Sast(i-1,n) + r(i,n,fv)*Y(i,n), inf, Sast(i-1,n) + r(i,n,fv)*Y(i,n)) + dblquad(f2(i,n), Sast(i-1,n) + r(i,n,fv)*Y(i,n), -inf, Sast(i-1,n) + r(i,n,fv)*Y(i,n), -inf);
end
end
I made lots of code..but can't sure why it's not work

댓글 수: 3

José-Luis
José-Luis 2013년 5월 21일
And what does the debugger say? What does "does not work" mean?
Sunghye
Sunghye 2013년 5월 22일
Error using fcnchk (line 103) If FUN is a MATLAB object, it must have an feval method.
Error in dblquad (line 54) intfcn = fcnchk(intfcn);
Error in work03 (line 159) C2_1(i,n)=dblquad(z(i,n),inf,Sast(i-1,n),-inf,Sast(i-1,n))
Walter Roberson
Walter Roberson 2013년 5월 22일
Yes, because sym objects do not have an feval() method.

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

 채택된 답변

Walter Roberson
Walter Roberson 2013년 5월 21일

0 개 추천

You are creating f1 and f2 as symbolic expressions, but you are attempting ot use dblquad() to do the integration. dblquad() takes a function handle, not a symbolic expression. Try
C2_1(i,n)=dblquad(matlabFunction(z(i,n)),inf,Sast(i-1,n),-inf,Sast(i-1,n))
Are you sure you want to go from +infinity downward to Sast(i-1,n) for the first variable? You go from -infinity upward to Sast(i-1,n) for the second variable.

댓글 수: 1

Sunghye
Sunghye 2013년 5월 22일
편집: Sunghye 2013년 5월 22일
Thank you, Walter It works!!! However, the answer is NaN(maybe not a NUMBER) What's the NaN mean?
error message is following
Warning: Infinite or Not-a-Number function value encountered. > In quad at 105 In dblquad>innerintegral at 82 In quad at 72 In dblquad at 58 In work03 at 159

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

추가 답변 (0개)

카테고리

Community Treasure Hunt

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

Start Hunting!

Translated by