MATLAB应用——曲线长度的求解

**

MATLAB应用——曲线长度的求解

**
曲线长度由于图形的不规则形,常常面临其长度(周长)不易求的问题。本文以椭圆和抛物线为例,介绍不规则曲线长度的求解方法。
【椭圆的周长】
问题:计算椭圆x^2/4+ y2=1
思路1:现将椭圆分割成1000等份,对每一份采用短直线代替短曲线(弧长微元)的方法,最后将所有1000份短直线进行累加,即可求出曲线长度。
程序1
s=0;
dx=0.001;
for x=0:0.001:1.999
dy=(1.-((x+0.001).2)/4)-(1.-((x).2)/4);
ds=sqrt(dx.2+dy.2);
s=s+ds;
end
s=4s;
fprintf(‘the length is’)
fprintf(’%.4f\n’,s)
程序2
t=0:0.001:2
pi;
a=2;
b=1;
x1=asin(t);%%x即为椭圆周上的点的横坐标
y1=b
cos(t);%%y即为椭圆周上的点的纵坐标
plot(x1,y1);
S=trapz(x1,y1) %这是求面积的
X=[0 x1(1:end-1)];
Y=[0 y1(1:end-1)];
x1=x1-X;
y1=y1-Y;
d=sqrt(x1.2+y1.2);
d=sum(d)
运算结果:
the length is9.1823
S = 6.2828
d = 10.6881
思路2:采用第一曲线积分。
MATLAB应用——曲线长度的求解
程序3:
syms x3;
f3=int(sqrt(4cos(x3)2+sin(x3)2),0,pi/2)
l3=mfun(‘EllipticE’,1/2
3^(1/2))
L=4*(2l3)
运行结果:
f3 =
2
EllipticE(1/2*3^(1/2))
l3 =
1.2111
L =
9.6884
【抛物线】
介绍抛物线y=ax^2+bx+c,在一段区间上的曲线长度的积分表示。
MATLAB应用——曲线长度的求解
编写程序,将abc与mn带入即可得到曲线的长度。

附:mfun的函数说明

help mfunlist
MFUNLIST Special functions for MFUN.
The following special functions are listed in alphabetical order according to the third column. n denotes an integer argument,
x denotes a real argument, and z denotes a complex argument. For more detailed descriptions of the functions, including any argument restrictions, see the Reference Manual, or use MHELP.

bernoulli n Bernoulli Numbers
bernoulli n,z Bernoulli Polynomials
BesselI x1,x Bessel Function of the First Kind
BesselJ x1,x Bessel Function of the First Kind
BesselK x1,x Bessel Function of the Second Kind
BesselY x1,x Bessel Function of the Second Kind
Beta z1,z2 Beta Function
binomial x1,x2 Binomial Coefficients
EllipticF - z,k Incomplete Elliptic Integral, First Kind
EllipticK - k Complete Elliptic Integral, First Kind
EllipticCK - k Complementary Complete Integral, First Kind
EllipticE - k Complete Elliptic Integrals, Second Kind
EllipticE - z,k Incomplete Elliptic Integrals, Second Kind
EllipticCE - k Complementary Complete Elliptic Integral, Second Kind
EllipticPi - nu,k Complete Elliptic Integrals, Third Kind
EllipticPi - z,nu,k Incomplete Elliptic Integrals, Third Kind
EllipticCPi - nu,k Complementary Complete Elliptic Integral, Third Kind
erfc z Complementary Error Function
erfc n,z Complementary Error Function’s Iterated Integrals
Ci z Cosine Integral
dawson x Dawson’s Integral
Psi z Digamma Function
dilog x Dilogarithm Integral
erf z Error Function
euler n Euler Numbers
euler n,z Euler Polynomials
Ei x Exponential Integral
Ei n,z Exponential Integral
FresnelC x Fresnel Cosine Integral
FresnelS x Fresnel Sine Integral
GAMMA z Gamma Function
harmonic n Harmonic Function
Chi z Hyperbolic Cosine Integral
Shi z Hyperbolic Sine Integral
GAMMA z1,z2 Incomplete Gamma Function
W z Lambert’s W Function
W n,z Lambert’s W Function
lnGAMMA z Logarithm of the Gamma function
Li x Logarithmic Integral
Psi n,z Polygamma Function
Ssi z Shifted Sine Integral
Si z Sine Integral
Zeta z (Riemann) Zeta Function
Zeta n,z (Riemann) Zeta Function
Zeta n,z,x (Riemann) Zeta Function

    Orthogonal Polynomials (Extended Symbolic Math Toolbox only)

T n,x Chebyshev of the First Kind
U n,x Chebyshev of the Second Kind
G n,x1,x Gegenbauer
H n,x Hermite
P n,x1,x2,x Jacobi
L n,x Laguerre
L n,x1,x Generalized Laguerre
P n,x Legendre