Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Jack H.Dynamic system modeling and control.2004.pdf
Скачиваний:
73
Добавлен:
23.08.2013
Размер:
5.61 Mб
Скачать

numerical methods - 4.31

4.5 DIFFERENTIATION AND INTEGRATION OF EXPERIMENTAL DATA

When doing experiments, data is often collected in the form of individual data points (not as complete functions). It is often necessary to integrate or differentiate these values. The basic equations for integrating and differentiating are shown in Figure 4.30. Given data points, y, collected at given times, t, we can integrate and differentiate using the given equations. The integral is basically the average height of the two points multiplied by the width to give an area, or integral. The first derivative is basically the slope between two points. The second derivative is the change in slope values for three points. In a computer based system the time points are often equally spaced in time, so the difference in time can be replaced with a sample period, T. Ideally the time steps would be as small as possible to increase the accuracy of the estimates.

 

 

 

y( t)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

yi + 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

yi

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

yi 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ti 1

 

 

 

T

 

 

 

ti

 

 

 

 

T

ti + 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ti

 

y( t ) dt

 

y

i

+ y

i 1

( t

 

t

 

 

)

=

T

( y

 

+ y

)

 

 

------------------------

i

i 1

--

i

 

 

 

i

 

 

 

 

 

 

 

2

 

 

 

 

 

 

 

2

 

 

 

i 1

 

ti 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

d

 

 

y

i

y

i 1

 

 

y

i + 1

y

 

1

 

 

 

 

 

1

 

 

 

 

 

 

 

 

 

 

 

i

 

 

 

 

 

 

 

----

y( ti) ≈

 

-----------------------

 

 

=

------------------------

 

 

= --( yi

 

yi 1) = --( yi + 1 yi)

dt

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ti

ti 1

 

ti + 1

ti

 

T

 

 

 

 

 

T

 

 

 

 

 

 

1

( y

 

 

 

 

 

 

 

1

( y

 

y

 

 

)

 

 

 

 

 

 

 

d

2

 

 

 

--

i + 1

y ) – --

i

 

 

 

 

2yi

+ yi 1

+ yi + 1

 

 

T

 

 

 

i

 

T

 

 

i 1

=

----

y( t )

 

------------------------------------------------------------------------

----------------------------------------------------

dt

 

i

 

 

 

 

 

 

 

 

 

 

 

T

 

 

 

 

 

 

 

 

 

 

 

 

2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

T

 

Figure 4.30 Integration and differentiation using data points

numerical methods - 4.32

An example of numerical integration using Scilab is given in Figure 4.31 and Figure 4.32.

//

// integrate.sce

//

// A simple program to integrate a function

//

// To run this in Scilab use 'File' then 'Exec'.

//

//by: H. Jack Sept., 9, 2002

//define the function

function foo=f(x)

foo = 5 * x + 2 * log(sin(x) / x + 2); endfunction

// Set the time length and step size steps = 10;

x_start = 1; x_end = 10;

x_delta = (x_end - x_start) / steps;

//

// Loop for rectangular integration

//

total = 0; // set the initial sum to zero for i=0:steps,

x = x_start + i * x_delta; total = total + f(x);

end

total = total * x_delta;

printf("Rectangular integration value %f\n", total);

Figure 4.31 Integration with a Scilab program