Numerical integration with constant parameters
조회 수: 32 (최근 30일)
이전 댓글 표시
how to do numerical integration with constant parameters?
for example:
f=(sin(thea)*dot([sin(thea)*cos(phia) sin(thea)*sin(phia) cos(thea)],[a*cos(thea) b*sin(thea) c*sin(thea)*cos(phia))*(3*cos(thea)*cos(thea)-1)/2
I want to do integration with thea and phia from 0-pi and 0-2*pi, respectively.
a b c are constant parameters.
What kind of functions should I use? Because like quad, dblquad can not deal with symbolic.
Thanks so much.
댓글 수: 0
답변 (1개)
Andrei Bobrov
2013년 6월 10일
편집: Andrei Bobrov
2013년 6월 10일
f = @(thea,phia,a,b,c)sin(thea)*dot([sin(thea)*cos(phia) sin(thea)*sin(phia) cos(thea)],[a*cos(thea) b*sin(thea) c*sin(thea)*cos(phia)])*(3*cos(thea)*cos(thea)-1)/2;
a = 1; b = 1; c = 1;
dblquad(@(thea,phia)f(thea,phia,a,b,c),0,pi.0,2*pi);
OR for symbolic
syms thea phia a b c
f = sin(thea)*dot([sin(thea)*cos(phia) sin(thea)*sin(phia) cos(thea)],[a*cos(thea) b*sin(thea) c*sin(thea)*cos(phia)])*(3*cos(thea)*cos(thea)-1)/2;
fm = matlabFunction(f);
a = 1; b = 1; c = 1;
dblquad(@(thea,phia)fm(thea,phia,a,b,c),0,pi.0,2*pi);
댓글 수: 3
VBBV
2025년 2월 17일
syms thea phia a b c
f = sin(thea)*dot([sin(thea)*cos(phia) sin(thea)*sin(phia) cos(thea)],[a*cos(thea) b*sin(thea) c*sin(thea)*cos(phia)])*(3*cos(thea)*cos(thea)-1)/2;
fm = matlabFunction(f);
a = 1; b = 1; c = 1;
dblquad(@(thea,phia)fm(thea,phia,a,b,c),0,pi,0,2*pi) % use a comma for integration limits
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!