Integrating a multivariate function (5 variables)
5 次查看(过去 30 天)
显示 更早的评论
I have a monster function that i need to integrate and plot, this is the function:
![function.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/257552/function.png)
I surfed and searched a lot of posts for a method to solve that, but in the end I failed, the best I did was:
syms w1 w0 w L g
fun(w1,w0,w,L,g)=2.*L.*g./pi.*(w1.^2/(((w0.^2-w1.^2).^2+g.^2.*w1.^2).*(w1.^2-w.^2)));
funt=int(fun,w1,0,Inf);
% SymResult = subs(funt,L,1);
% SymResult = subs(funt,w0,1);
% SymResult = subs(funt,g,1);
% SymResult = subs(funt,w,1);
% pretty(SymResult)
ezplot(SymResult)
But i get some monstrous result that even substitute function doesn't work... Is there any way to solve this numerically and to plot it?
Big thanks in advance.
(I tried to substitute values in the function, because ezplot can only plot function of one unknown)
0 个评论
回答(1 个)
Thiago Henrique Gomes Lobato
2019-12-29
You first have to define what you want to plot it. This seems to be a function of w, so, for different w's you want to integrate over w1 and all other values should be fixed, is that right? You can do it numerically as follows:
L = 0.1;
g = 2;
w0 = pi/4;
t = 1;
wvec = -2*pi:0.1:2*pi;
for w = wvec
fun = @(w1)2.*L.*g./pi.*(w1.^2./(((w0.^2-w1.^2).^2+g.^2.*w1.^2).*(w1.^2-w.^2)));
q(t) = integral(fun,0,Inf);
t = t+1;
end
figure,plot(wvec,q)
The main problem is that your function has a singularity at w=w1, which will create a division by zero and thus the result you get from the numerical integral will not be right, and also you cannot expect a reasonable value from the integral itself. Are you maybe missing some term in the equation?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!