P. 1
Solving Applied Mathematical Problems With MATLAB

# Solving Applied Mathematical Problems With MATLAB

|Views: 11,981|Likes:

### Availability:

See more
See less

07/15/2013

pdf

text

original

Computation via Gr¨unwald-Letnikov deﬁnitions

The most straightforward way in evaluating the fractional-order derivatives

numerically is to use the Gr¨unwald-Letnikov deﬁnition which is given again

t f(t) = lim
h→0

1

[(t−a)/h]
j=0

(−1)j

α
j

f(t−jh)≈ 1

[(t−a)/h]
j=0

w(α)

j f(t−jh)

(10.31)

where the binomial coeﬃcientsw(α)

j = (−1)j

α
j

can be evaluated recursively

from

w(α)

0 = 1, w(α)

j =

1− α + 1
j

w(α)

j−1, j = 1,2,··· .

(10.32)

401

If the step-size h is small enough, (10.31) can be used directly to calculate

approximately the values of the fractional-order derivatives, with an accuracy

of o(h)[60]

. The following MATLAB function can be written, with the syntax

y1=glfdiff(y,t,γ), where y,t describe the original function using evenly

distributed samples. The returned vector y1 is the γth order derivative.

1 function dy=glfdiff(y,t,gam)

2 h=t(2)-t(1); dy(1)=0; y=y(:); t=t(:);

3 w=1; for j=2:length(t), w(j)=w(j-1)*(1-(gam+1)/(j-1)); end

4 for i=2:length(t), dy(i)=w(1:i)*[y(i:-1:1)]/h^gam; end

Example 10.37 For function f(t) = e−t

sin(3t+1), t(0,π), study the behaviors

of the fractional-order derivatives.

Solution Select the step-sizes, T = 0.01 and 0.001, the 0.5th order derivative can

be evaluated as shown in Figure 10.42 (a). It can be seen that, when t is close to 0,

there are some diﬀerences. For larger t, the two solutions are very close. Normally

speaking, selecting T = 0.01 may give accurate results.

>> t=0:0.001:pi; y=exp(-t).*sin(3*t+1); dy=glfdiff(y,t,0.5); plot(t,dy);

t=0:0.01:pi; y=exp(-t).*sin(3*t+1); dy=glfdiff(y,t,0.5); line(t,dy)

For diﬀerent selections of γ, the 3D surface representation of the fractional-order

derivative can be obtained as shown in Figure 10.42 (b).

>> Z=[]; t=0:0.01:pi; y=exp(-t).*sin(3*t+1);

for gam=0:0.1:1, Z=[Z; glfdiff(y,t,gam)]; end

surf(t,0:0.1:1,Z); axis([0,pi,0,1,-1.2,6])

0 0.5 1 1.5 2 2.5 3 3.5

−2

0

2

4

6

8

10

12

14

(a) comparisons under diﬀerent step-sizes

0

1

2

3

0

0.5

1

0

2

4

6

γ

t

(b) fractional-order derivative surface

FIGURE 10.42: Fractional-order diﬀerentiation of the function

Example 10.38 Consider a sinusoidal function f(t) = sin(3t + 1). Find its

0.75th order derivative with Gr¨unwald-Letnikov deﬁnition and Cauchy’s formula,

and compare the results.

Solution According to Cauchy’s formula and (10.18), the 0.75th order derivative

can be obtained as 0D0.75

t f(t) = 30.75

sin(3t+ 1 + 0.75π/2). With the Gr¨unwald-

Letnikov deﬁnition, the derivative can be evaluated with glfdiff() function. The

two derivative curves are compared in Figure 10.43 (a).

402

Solving Applied Mathematical Problems with MATLAB

0 0.5 1 1.5 2 2.5 3 3.5

−4

−2

0

2

4

6

8

Gr¨unwald-Letnikov deﬁnition

C
a
u
c
h
y
’s

(a) comparisons of diﬀerent deﬁnitions

0

1

2

3

4

0

0.5

1

−4

−2

0

2

4

γ

t

(b) 3D surface by Cauchy’s formula

FIGURE 10.43: Comparisons and 3D surfaces

>> t=0:0.01:pi; y=sin(3*t+1); y1=3^0.75*sin(3*t+1+0.75*pi/2);

y2=glfdiff(y,t,0.75); plot(t,y1,t,y2,’--’)

It can be seen that when t is small, there exists signiﬁcant diﬀerence between the

two deﬁnitions. This is because, in these two deﬁnitions, the assumptions of the

function at t < 0 are considered diﬀerently. In Cauchy’s formula, it is assumed that

the function can also be described by f(t) = sin(3t + 1) when t < 0, however, for

Gr¨unwald-Letnikov deﬁnition, it is assumed that f(t) = 0 for t < 0. Thus in the

later case, there is a jump at t = 0, which causes the diﬀerence.

Again, the 3D surface can also be found for diﬀerent orders γ, with the following

statements, as shown in Figure 10.43 (b). It can be seen that the fractional-order

derivatives provide information between the original function and its ﬁrst-order

derivative.

>> gam=[0:0.1:1]; Y=[]; t=0:0.01:pi; y=sin(3*t+1);

for a=gam, Y=[Y; 3^a*sin(3*t+1+a*pi/2)]; end

surf(t,gam,Y)

Using ﬁltering algorithm to compute the fractional-order calculus

In the fractional-order derivative evaluation method discussed above, the
function f(t) or its samples are known. In many other applications, the signal

f(t) is generated dynamically. In this case, a ﬁlter can be designed to evaluate

fractional-order derivative of f(t) in real-time.

For the fractional-order derivative, its Laplace representation is sγ

, which

exhibits straight lines in both Bode magnitude and phase plots. Thus it

is not possible to ﬁnd a ﬁnite order ﬁlter to ﬁt the straight lines for all
the frequencies. However, it is useful to ﬁt the frequency responses over a

frequency range of interest.

Diﬀerent continuous ﬁlters have been studied in Reference [61], among

which the Oustaloup’s ﬁlter[62]

has certain advantages. For the selected

frequency range of interest, (ωb,ωh), the continuous ﬁlter can be written as

Gf(s) = K

N

k=−N

s +ω′

k
s +ωk

(10.33)

403

where, the poles, zeros and gain can be evaluated from

ω′

k = ωb

ωh
ωb

k+N+1

2(1−γ)

2N+1

, ωk = ωb

ωh
ωb

k+N+1

2(1+γ)

2N+1

, K = ωγ

h. (10.34)

Based on the above algorithm, the following function can be written

1 function G=ousta_fod(r,N,wb,wh)

2 mu=wh/wb; k=-N:N; w_kp=(mu).^((k+N+0.5-0.5*r)/(2*N+1))*wb;

3 w_k=(mu).^((k+N+0.5+0.5*r)/(2*N+1))*wb;

4 K=wh^r; G=tf(zpk(-w_kp’,-w_k’,K));

The continuous ﬁlter can be designed as G=ousta fod(γ,N,ωb,ωh), where

γ is the order of derivative, and 2N + 1 is the order of the ﬁlter.

Example 10.39 Select the frequency range of interest as ωb = 0.01,ωh =

100 rad/sec, and design the continuous-time approximate fractional-order ﬁlters.

For the function f(t) = e−t

sin(3t + 1), calculate the 0.5th order derivative and

verify the obtained results.

Solution The 5th order and 7th order ﬁlters can be designed

>> G1=ousta_fod(0.5,2,0.01,100),

G2=ousta_fod(0.5,3,0.01,100), bode(G1,G2),

such that

G1(s) = 10s5

+ 298.5s4

+ 1218s3

+ 768.5s2

+ 74.97s + 1

s5

+ 74.97s4

+ 768.5s3

+ 1218s2

+ 298.5s + 10 ;

G2(s) = 10s7

+509.4s6

+5487s5

+14988s4

+10786.7×104

s3

+2045s2

+98.34s+1

s7

+98.34s6

+2045s5

+1.079×104

s4

+1.499×104

s3

+5487s2

+509.4s+10.

The Bode diagrams of the above approximate ﬁlter are shown in Figure 10.44 (a),

superimposed by the theoretical straight lines. The ﬁlter output is shown in Fig-

ure 10.44 (b). Moreover, the 0.5th order derivative obtained through Gr¨unwald-

Letnikov deﬁnition can be obtained using the following MATLAB scripts and the

obtained derivative curve is also shown in Figure 10.44 (b). Clearly, the ﬁlter output

of this example is fairly accurate.

>> t=0:0.001:pi; y=exp(-t).*sin(3*t+1);

y1=lsim(G1,y,t); y2=lsim(G2,y,t); y0=glfdiff(y,t,0.5);

plot(t,y1,t,y2,t,y0)

Of course, if one is not satisﬁed with the ﬁlters, the frequency range of interest

and the order of the ﬁlter can both be increased.

A modiﬁed Oustaloup ﬁlter

In practical applications, it is frequently found that the ﬁlter from using
the ousta fod() function cannot exactly ﬁt the whole expected frequency

range of interest. A new improved ﬁlter for a fractional-order derivative in

404

Solving Applied Mathematical Problems with MATLAB

−30

−20

−10

0

10

20

30

M

agnitude (dB)

10−3

10−2

10−1

100

101

102

103

0

30

60

Phase (deg)

Bode Diagram

(a) diﬀerent order of ﬁlters

0 0.5 1 1.5 2 2.5 3 3.5

−1

−0.5

0

0.5

1

1.5

2

(b) derivative curves

FIGURE 10.44: Comparisons of approximate fractional-order ﬁlters

the frequency range of interest [ωb,ωh], which is shown to perform better, is

introduced in this subsection. The modiﬁed ﬁlter is[63]

dωh
b

γ

ds2

+bωhs

d(1−γ)s2

+bωhs +dγ

N

k=−N

s+ω′

k
s+ωk

(10.35)

where

ω′

k = ωb

ωh
ωb

k+N+1

2(1−γ)

2N+1

, ωk = ωb

ωh
ωb

k+N+1

2(1+γ)

2N+1

. (10.36)

Through a number of experimentation conﬁrmation and theoretic analyses,

the modiﬁed ﬁlter achieves good approximation when b = 10 and d = 9. With
the above algorithm, a MATLAB function new fod() is written

1 function G=new_fod(r,N,wb,wh,b,d)

2 if nargin==4, b=10; d=9; end

3 mu=wh/wb; k=-N:N; w_kp=(mu).^((k+N+0.5-0.5*r)/(2*N+1))*wb;

4 w_k=(mu).^((k+N+0.5+0.5*r)/(2*N+1))*wb; K=(d*wh/b)^r;

5 G=zpk(-w_kp’,-w_k’,K)*tf([d,b*wh,0],[d*(1-r),b*wh,d*r]);

with the syntax Gf=new fod(γ,N,ωb,ωh,b,d).

Example 10.40 Consider a model G(s) =

s+ 1

10s3.2

+ 185s2.5

+ 288s0.7

+ 1, which

is a fractional-order model. Compare the two Oustaloup ﬁlters.

Solution The exact Bode diagram can be obtained with the bode() function.

The approximations to the 0.2th order derivative using the Oustaloup’s ﬁlter and

the modiﬁed Oustaloup’s ﬁlter can be obtained as shown in Figure 10.45 (a). The

frequency range of good ﬁtting is larger with the improved ﬁlter. Also the approx-

imation to the G(s) model is shown in Figure 10.45 (b). It can be seen that the

modiﬁed method provided a much better ﬁt.

>> b=[1 1]; a=[10,185,288,1]; nb=[1 0]; na=[3.2,2.5,0.7,0];

w=logspace(-4,4,200); G0=fotf(a,na,b,nb); H=bode(G0,w);

405

s=zpk(’s’); N=4; w1=1e-3; w2=1e3; b=10; d=9;

g1=ousta_fod(0.2,N,w1,w2); g2=ousta_fod(0.5,N,w1,w2); a1=g1;

g3=ousta_fod(0.7,N,w1,w2); G1=(s+1)/(10*s^3*g1+185*s^2*g2+288*g3+1);

g1=new_fod(0.2,N,w1,w2,b,d); g2=new_fod(0.5,N,w1,w2,b,d);

g3=new_fod(0.7,N,w1,w2,b,d); bode(g1,a1); figure

G2=(s+1)/(10*s^3*g1+185*s^2*g2+288*g3+1); bode(H,G1,G2)

−40

−30

−20

−10

0

10

20

M

agnitude (dB)

10−4

10−2

100

102

104

0

45

90

Phase (deg)

Bode Diagram

← modiﬁed

Oustaloup’s

← modiﬁed

← Oustaloup’s

(a) s0.2

ﬁttings

−200

−150

−100

−50

0

M

agnitude (dB)

10−4

10−2

100

102

104

−180

−135

−90

−45

0

Phase (deg)

Bode Diagram