dynAvgWT()

Returns the average of the elements of the dynamic field x.

Synopsis

float dynAvgWT(unsigned order, time t1, time t2, <dyn_type> x, dyn_time t [, dyn_bool mask]);

Parameters

Parameter Meaning
order Determines type of averaging
t1, t2 Limiting the time interval
x dynamic field from which the calculation is made
t time field
mask masking field

Return Value

In the event of errors 0 ! is returned, otherwise the average.

Errors

An error is issued in the event of incorrect or missing arguments if x is not a dynamic field (array)

Description

Returns the time average of the elements of the dynamic field x. Their type can either be dyn_int, dyn_uint or dyn_float. The averaging is made over the interval t2-t1. The first element of the time field t must be smaller than or equal to t1. If the last element of t is smaller than t2, averaging is only up to this point, not to t2! If the last element of t is smaller than t1, the value associated with t1 x(t1) is ascertained by interpolation of x[2]. If the last element of t is higher than t2, x(t2) is defined by interpolation of the penultimate element of x. Averaging can only be carried out in zeroed order over a stepped curve or in first order linearly, which is decided by setting the parameter order to zero or one.

dynAvg0() =

dynAvg1() =

The optional argument mask functions in the same way as in dynMax().

Example

First two fields are initialized: A time field dt and an integer field di, which symbolizes the values in parallel to the times. The time average is finally output by means of DebugN in the log viewer.

main()
{
  time t;
  dyn_int di;
  dyn_time dt;
  t=makeTime(1999,8,15,12,30);
  dt=makeDynTime(t,t+30,t+60,t+90,t+120,t+150,t+180);
  di=makeDynInt(1,2,3,4,5,6,7);
  DebugN("dynAvgWT:",dynAvgWT(1,dt[1],dt[7],di,dt));
}

Assignment

Dynamic fields

Availability

CTRL