# Operations on Datafiles

Many standard Matlab operations are overloaded for variables of the datafile type. They are just stored as an operation inside the variable and only executed at the moment the datafile is converted into a dataset. All annotations like labels are preserved during the operation. In case of dyadic operations the annotation of the first datafile is used for the resulting datafile.

 Examples of standard `Matlab` operations applied to datafiles B = A([3 6 7],:) Construct a new datafile with just the objects `3`, `6` and `7` of `A`. C = [A;B] Add the objects of datafile `B` to those of `A`. `A` and `B` should be subsets of the same original datafile. B = A+7 Add `7` to all elements of all objects of `A` C = ((A>0.5).* A*7) + (A<=0.5).*A Multiply all elements of `A` that are larger than `0.5` by `7` mean(A,2) Returns a column vector of object averages. std(A,[],2) Returns a column vector of object standard deviations.

The following `Matlab` operators are defined for datafiles:

`    +, -, *, .*, .^ , /, , ./, |, &, ~, xor, abs`

Dyadic operations like C = A+B have severe restrictions. They are only implemented for datafiles `A` and `B` that refer to the same original datafile. So `A` and `B` should both be the result of, most likely different, operations on the same underlying original datafile. For instance, `(C==1) & (im_unif(C)<0.9)`, which finds the inner contour pixels, is a valid operation as the two inputs `C==1` and `im_gauss(C)<0.9` refer to the same datafile `C`.

For dyadic operations the annotation of the first datafile is used for the resulting datafile. Dyadic operations of datafiles and arrays of doubles are supported, provided that the dimensions fit. So all objects should have the same size for operations like this.

The logic operations

`     >, >=, <, <=, =, ~=`

applied to datafiles return binary images in case images are stored in the datafile.

The following `Matlab` commands are overloaded for datafiles are: `abs`, `double`, `sum`, `min`, `max`, `mean`, `median`, `log`, `exp`, `find`, `hist`, `isempty`, `isfinite`, `isnan`, `size`, `length`, `plot`, `real`, `sqrt`. Monadic operations not overloaded for datafiles can be defined by `filtm`, e.g.:

``B = filtm(A,'log10')``