How can I calculate integral?

조회 수: 4 (최근 30일)
Serhat . 2012년 9월 18일
Hi all, I am new to matlab. I am using matlab R2012. I am trying to calculate this integral:
sigmaZ=rand(4,4); syms theta; Ps = 1/pi*(int(1./(det( (sigmaZ./(sin(theta)).^2 + eye(4)))),theta,0,pi/2));
It gives this error message:
?? The following error occurred converting from sym to double: Error using ==> mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
What is the problem here? Can you help me?
Thanks in advance!
  댓글 수: 1
Alexander 2012년 9월 18일
That's strange, I don't get that error. I do get this warning:
Warning: Explicit integral could not be found.
Sorry, no idea why this is happening.

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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 9월 18일
편집: Andrei Bobrov 님. 2012년 9월 18일
please try this is code:
f = @(theta)1./(arrayfun(@(x)det(sigmaZ/sin(x).^2 + eye(4)),theta));
out = quad(f,0,pi/2);
  댓글 수: 4
Javier 2012년 9월 18일
It gives me no solution.
f = @(theta)1./(arrayfun(@(x)det(((sigmaZ/sin(x).^2 + eye(4)).^-1)*exp((sin(x).^2*eye(4)).^-1)),theta));
out = quad(f,0,pi/2);

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

추가 답변 (1개)

Javier 2012년 9월 18일
Hello Serhat
I dont understand well the integral expression and limits of integration. To solve numerically integrals in MatlabR 2012a (or previous version).
Create a function with the integral expression.
Next, use qaudl function (in the command window type: doc quadl)
Value=quadl(f,0,1) % 0 and 1 are the limits of integration of f
Hope it helps. Best regards and welcome to Matlab world.


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

Community Treasure Hunt

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

Start Hunting!

Translated by