Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
数值积分勒让德多项式MATLAB_Matlab_Numerical Methods_Numerical Integration - Fatal编程技术网

数值积分勒让德多项式MATLAB

数值积分勒让德多项式MATLAB,matlab,numerical-methods,numerical-integration,Matlab,Numerical Methods,Numerical Integration,勒让德多项式在MATLAB中作为向量实现,在这里还可以得到在特定点x处计算的所有相关勒让德多项式。因此,我不知道如何在积分中使用这些函数。我的问题是: 如何在Matlab中计算第n个勒让德多项式上从-1到1的(数值计算的(!)积分 编辑:因为我收到的答案并不是我想要的:我想在MATLAB中使用勒让德多项式的实现,因为其他建议可能非常不稳定 正如@thewaywewalk提到的,你可以使用trapz进行数值积分 n阶勒让德多项式定义为: 因此,您可以在Matlab中定义它们,如下所示: sym

勒让德多项式在MATLAB中作为向量实现,在这里还可以得到在特定点x处计算的所有相关勒让德多项式。因此,我不知道如何在积分中使用这些函数。我的问题是:

如何在Matlab中计算第n个勒让德多项式上从-1到1的(数值计算的(!)积分


编辑:因为我收到的答案并不是我想要的:我想在MATLAB中使用勒让德多项式的实现,因为其他建议可能非常不稳定

正如@thewaywewalk提到的,你可以使用trapz进行数值积分

n阶勒让德多项式定义为:

因此,您可以在Matlab中定义它们,如下所示:

sym x % You probably have to define x as being symbolic since you integrate as a function of x.
x = -1:0.1:1;

n = 1; Change according to the degree of the polynomial.

F = (x.^2)-1).^n;

Pol_n = (1./((2.^n).*factorial(n))).*diff(F,x,n) % n is the degree of the polynomial
然后使用trapz:

Output = trapz(x,Pol_n)

这应该会让你走起来。

正如@wewalk提到的那样,你可以使用trapz进行数值积分

n=3 % degree of Legendre polynomial
step=0.1 % integration step
trapz(legendre(n,-1:step:1)')*step
n阶勒让德多项式定义为:

因此,您可以在Matlab中定义它们,如下所示:

sym x % You probably have to define x as being symbolic since you integrate as a function of x.
x = -1:0.1:1;

n = 1; Change according to the degree of the polynomial.

F = (x.^2)-1).^n;

Pol_n = (1./((2.^n).*factorial(n))).*diff(F,x,n) % n is the degree of the polynomial
然后使用trapz:

Output = trapz(x,Pol_n)
那会让你走的

n=3 % degree of Legendre polynomial
step=0.1 % integration step
trapz(legendre(n,-1:step:1)')*step
这应该是你想要的


这应该是你想要的

数值积分的Matlab函数是
trapz
cumtrapz
@thewaywewalk是的,但我不明白我是如何让他在勒让德多项式上积分的。数值积分的Matlab函数是
trapz
cumtrapz
@thewaywewalk是的,但我不明白我是如何让他在勒让德多项式上积分的。不,我想用它们,它们在MATLAB中的实现方式,因为这种直接定义是高度不稳定的(数值)。看这里不,我想使用它们,它们在MATLAB中的实现方式,因为这种直接定义是高度不稳定的(数值)。看这里