Numerical integration with constant parameters
33 次查看(过去 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!