gridfile.arithmetic

Arithmetic operations across two gridfiles


Syntax



Description

obj.arithmetic(operation, grid2, filename, overwrite, atts, type, precision)

Implement an arithmetic operation on the data in two .grid files. Saves the result of the operation to a .mat file and catalogues the result in a new .grid file.


Input Arguments

operation

plus’ | ‘minus’ | ‘times’ | ‘divide
The arithmetic operation to apply to the two gridfiles

grid2

string scalar | gridfile object
The second gridfile to use in the arithmetic operation.

filename

string scalar | string vector [2]
The name to use for the new .mat and .grid files. If a single file name, the name will be used for both files. If two file names, the first name is used for the .mat file, and the second name is used for the .grid file.

overwrite

scalar logical | logical vector [2]
Whether to overwrite existing .mat and .grid files. True allows overwriting, false does not. If scalar, uses the same option for both files. If two elements, uses the first option for the .mat file, and the second option for the .grid file. Default is false.

attributes

1 | 2 | scalar struct | empty array
Options for setting metadata attributes in the new .grid file. If 1, copies the attributes from the first gridfile to the new file. If 2, copies the attributes from grid2 to the new file. If a scalar struct, uses the struct directly as the attributes. If unset or an empty array, the new file will have no metadata attributes.

type

1 | 2 | 3
Options for matching gridfile metadata and sizes.

[1 (default)]: requires data dimensions to have compatible sizes AND have the same metadata along each non-singleton dimension. Does arithmetic on all data elements.

[2]: Searches for data elements with matching metadata in non-singleton dimensions. Only does arithmetic at these elements. Does not require data dimensions to have compatible sizes.

[3]: Does not compare dimensional metadata. Loads all data elements from both files and applies arithmetic directly. Requires data dimensions to have compatible sizes.

precision

[] | ‘single’ | ‘double
The required numerical precision of the final data. If ‘single’ or ‘double’, uses the specified type. If an empty array, uses double unless all data used for arithmetic is loaded as single by default.

Saves

A .mat and .grid file with the specified names.