Integrating with trapz and int

1 次查看(过去 30 天)
Nico Pisani
Nico Pisani 2020-12-28
Hi All.
I have the following code
syms theta
B=dlmread('630nm in ARF E_y cartesian coordinates.txt')
B1new = B(:,1)
B2new=B(:,2)
alpha=sqrt(B2new.^2+B1new.^2)
BS=[alpha]
CS=[conj(B(:,3))]
k=2.*pi./(630.*0.000000001)
bess=[besselj(0,k.*BS.*sin(theta)).*tan(theta).*CS.*BS]
U=trapz(bess)
Bessint = int(U,theta,[0 0.6])
Fvpa = vpa(Bessint)
for calculating the following integral
CS, BS correspond respectively to \rho and E*(\pho) which are extracted from a .txt file.
The code has calculated symbolically U but after hours running it has not completed the Fvpa quantity calculation yet (editor reports "busy" status).
Matrices at stake are quite big (~40000 ins column)
May anyone help me please?
  1 个评论
John D'Errico
John D'Errico 2020-12-28
Get a faster computer. Use smaller matrices, solve smaller problems. Get some coffee, read a book while you wait (something long, and preferably about numerical methods in MATLAB.) Or, ... write better code.
Note that it is rarely a good idea to use trapz AND int in the same code. trapz being a numerical integration method with relatively low accuracy makes little sense in conjunction with a symbolic tool.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by