• 沒有找到結果。

Symbolic Math Toolbox Symbolic Math Toolbox

N/A
N/A
Protected

Academic year: 2021

Share "Symbolic Math Toolbox Symbolic Math Toolbox"

Copied!
16
0
0

加載中.... (立即查看全文)

全文

(1)

Symbolic Math Toolbox Symbolic Math Toolbox

 In order to enter a transfer function into MATLAB, In order to enter a transfer function into MATLAB, the variables used to contain numerical values must the variables used to contain numerical values must

be ‘converted’ to store

be ‘converted’ to store symbolic variables symbolic variables . This can . This can be done with MATLAB symbolic toolbox.

be done with MATLAB symbolic toolbox.

 Command Command

syms syms : Short-cut for constructing symbolic objects : Short-cut for constructing symbolic objects

All variables appearing on the right-hand-side must be All variables appearing on the right-hand-side must be symbolized.

symbolized.

 Syntax Syntax

syms arg1 arg2 syms arg1 arg2 ... ...

Type ‘ Type ‘ syms syms ’ to see what variables are symbolized. Use ’ to see what variables are symbolized. Use

‘ ‘ clear arg1 clear arg1 ’ to remove ’ to remove arg1 arg1 from this list. from this list.

(2)

1. Using Laplace 1. Using Laplace

Transform in MATLAB

Transform in MATLAB

(3)

Laplace Transform Laplace Transform

LAPLACE Laplace transform.

L = LAPLACE(F) is the Laplace transform of the scalar sym F with default default

independent variable t

independent variable t. The default The default return is a function of s

return is a function of s. If F = F(t), then LAPLACE returns a function of s: L = L(s).

By definition L(s) = int(F(t)*exp(-s*t),0,inf), where integration occurs with respect to t.

(Try typing ‘help laplace’ in MATLAB…)

(4)

L = LAPLACE(F,t) makes L a function of t instead of the default s:

LAPLACE(F,t) <=> L(t) = int(F(x)*exp(- t*x),0,inf).

L = LAPLACE(F,w,z) makes L a function of z instead of the

default s (integration with respect to w):

LAPLACE(F,w,z) <=> LAPLACE(F,w,z) <=>

L(z) = int(F(w)*exp(-z*w),0,inf).

L(z) = int(F(w)*exp(-z*w),0,inf).

We We d prefer to use d prefer to use laplace(f, t, s) laplace(f, t, s) , or simply , or simply laplace(f).

laplace(f).

(5)

Examples:

syms a s t w

laplace(t^5)

laplace(exp(a*t)) laplace(sin(w*t),s) laplace(cos(w*t),t,s)

laplace(heaviside(t),t,s) laplace(heaviside(t-2),t,s)

heaviside(ta) : Unit step function u(ta)

Declare those as symbols instead of numeric values.

All 2

nd

and 3

rd

arguments for laplace() are not really needed at all.

(6)

>> laplace(x^sym(3/2),t)

??? Undefined function or variable 'x'.

>> syms 'ans'

>> syms x

>> laplace(x^sym(3/2),t)

??? Undefined function or variable 't'.

>> syms 'ans' 'x'

>> syms t

>> laplace(x^sym(3/2),t) ans =

3/4*pi^(1/2)/t^(5/2)

f(t)= F(s)=

f(x)=x3/2

 F(t) = (3/2+1) / t

(3/2+1)

where  is the Gamma function defined as the following:

More examples:

(7)

Examples:

syms s t w

ilaplace(1/(s-1)) ilaplace(1/(s^2+1))

ilaplace(s/(s^2 + w^2),s,t) ilaplace(1/s,s,t)

ilaplace(exp(-2*s)/s,s,t)

Inverse Laplace Transform Inverse Laplace Transform

All 2

nd

and 3

rd

arguments for ilaplace() are not really needed at all.

(8)

Examples shown in the textbook Examples shown in the textbook

 Find the transforms of cosh Find the transforms of cosh at at and and sinh

sinh at at . .

 Find the Laplace transform of Find the Laplace transform of

f f ( ( t t ) = ) = e e

tt

(3cos20 (3cos20 t t   7sin20 7sin20 t t ). ).

(9)

Example 1 Example 1

 Consider the initial value problem Consider the initial value problem y y ” + 3 ” + 3 y y ’ + 2 ’ + 2 y y = = e e

tt

, , y y (0) = 4 and (0) = 4 and y y ’(0) = 5. ’(0) = 5.

 Solution steps: Solution steps:

Let f Let f ( ( t t ) be defined to the right-hand-side function. ) be defined to the right-hand-side function.

Use Laplace transform to convert Use Laplace transform to convert f f ( ( t t ) to ) to F F ( ( s s ). ).

Perform Laplace transform on Perform Laplace transform on y y ”, ”, y y ’ and ’ and y y , , incorporating the initial conditions. Note that

incorporating the initial conditions. Note that y y ( ( t t ) ) becomes

becomes Y Y( (s s). ).

From the resulting algebraic equation, solve for From the resulting algebraic equation, solve for Y Y ( ( s s ). ).

Use inverse Laplace transform to get Use inverse Laplace transform to get y y ( ( t t ) from ) from Y Y ( ( s s ). ).

(10)

Example 1 – cont’d Example 1 – cont’d

 Consider the initial value problem Consider the initial value problem y y ” + 3 ” + 3 y y ’ + 2 ’ + 2 y y = = e e

tt

, , y y (0) = 4 and (0) = 4 and y y ’(0) = 5. ’(0) = 5.

>> syms s t Y

>>

f=exp(-t);

f =

exp(-t)

>>

F=laplace(f ,t,s)

Declaring that these variables are symbolic.

Perform the transform on the non-homogeneous term first.

Part 1: 先求等號右邊的 laplace 轉換

(11)

11

Example 1 – cont’d Example 1 – cont’d

 Consider the initial value problem Consider the initial value problem y y ” + 3 ” + 3 y y ’ + 2 ’ + 2 y y = = e e

tt

, , y y (0) = 4 and (0) = 4 and y y ’(0) = 5. ’(0) = 5.

>> Y1=s*Y-4;

>> Y2=s*s*Y-s*4-5;

>> Sol=solve(Y2+3*Y1+2* Sol=solve(Y2+3*Y1+2* Y- Y - F F , , Y Y ) )

Sol =

(21*s+4*s^2+18)/(1+s)/

(3*s+2+s^2)

>> sol=ilaplace(Sol,s,t) sol =

-8*exp(-2*t)+(12+t)*exp(-t)

>> ezplot(f,[0,10])

>> ezplot(sol,[0,10])

Part 2: y’  sYy(0)

y”  s

2

Ysy(0)y’(0) = s[sYy(0)] y’(0) (s

2

+3s+2)Y=

(4s

2

+21s+18)/(s+1) y(t) = 8e

2t

+ 12e

t

+ te

t

These automatically make Y1 and Y2 symbolic, since Y and s are symbolic.

( ( F F ) )

(12)

Input to the system

Output from the system

f(t) = e

t

y(t) = 8e

2t

+ 12e

t

+ te

t

(13)

  0 1 , '   0 1

, 0 6

'

"  yyyy

y

(14)

  0 1 , '   0 31 . 5

, 3 64

9 25

. 2 ' 3

"  yytyy

y

(15)

Example 2 Example 2

 Consider the initial value problem Consider the initial value problem y y ” + 3 ” + 3 y y ’ + 2 ’ + 2 y y = = f f ( ( t t ), ), y y (0) = 2 and (0) = 2 and y y ’(0) = 3. ’(0) = 3. f f ( ( t t ) = 1 for ) = 1 for t t < 3, < 3, t t   2 for 3< 2 for 3< t t <6, <6,

and 2 for

and 2 for t t > 6. > 6.

For the three segments of f(t), we have the function represented by step function, respectively, as:

1 u(t 3) for t < 3,

(t 2)*[u(t 3)-u(t 6)] for 3 < t < 6, and 2*u(t 6) for t > 6

That is, f(t) = 1 u(t 3) + (t 2)*[u(t 3)-u(t 6)] + 2*u(t 6)

(16)

Input to the system

Output from the system

1 for t < 3,

t

2 for 3 < t < 6,

2 for t > 6

參考文獻

相關文件

In order to understand the influence level of the variables to pension reform, this study aims to investigate the relationship among job characteristic,

This kind of algorithm has also been a powerful tool for solving many other optimization problems, including symmetric cone complementarity problems [15, 16, 20–22], symmetric

In particular, the parabolic second-order directional differentiability of projec- tion operator was used to establish the expression of second-order tangent sets, which plays

A convenient way to implement a Boolean function with NAND gates is to obtain the simplified Boolean function in terms of Boolean operators and then convert the function to

Structured programming 14 , if used properly, results in programs that are easy to write, understand, modify, and debug.... Steps of Developing A

• A cell array is a data type with indexed data containers called cells, and each cell can contain any type of data. • Cell arrays commonly contain either lists of text

• A function is a piece of program code that accepts input arguments from the caller, and then returns output arguments to the caller.. • In MATLAB, the syntax of functions is

even if bound changes on non-binary variables are present, such a subset can be used like the conflict detecting clause in SAT to represent the conflict in the conflict graph..