问题描述
Legendre多项式在MATLAB中作为矢量实现,您还可以在所有特定点x上获得所有关联的Legendre多项式.因此,我不知道如何在积分中使用这些功能.我的问题是:
The Legendre polynomials are implemented in MATLAB as vectors, where you also get all the associated Legendre polynomials evaluated at a particular point x. Thus, I don't know how I can use these functions inside an integral. My question is:
我该如何在Matlab的第n个Legendre多项式中计算从-1到1的(NUMALICALCALCUALTED(!))积分?
How can I evaluate the (NUMERICALLY CALCUALTED(!)) integral from -1 to 1 over the n-th Legendre polynomial in Matlab?
当我收到的答案实际上不是我想要的答案:我想在MATLAB中使用Legendre多项式的实现,因为其他建议可能会非常不稳定.
As I received an answer that is really not what I want: I want to use the implementation of the Legendre polynomials in MATLAB cause other suggestions may be highly unstable.
推荐答案
n=3 % degree of Legendre polynomial
step=0.1 % integration step
trapz(legendre(n,-1:step:1)')*step
这应该做你想要的
这篇关于数值积分Legendre多项式MATLAB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!