Edit: Replace
Find and replace values in matrix using conditions
1. mreplace cond:=eq find:=1.3 abs_error:=0.1 replace:=13 use_abs:=1 keep_sign:=1
2. mreplace cond:=ne find:=1.1 set_missing:=1 replace:=0
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Matrix Object | im |
Input/Output MatrixObject |
|
Specify Input matrix. |
Condition | cond |
Input int |
|
Combined with the value of Find What, the selected operator in this list defines the condition used to find the values to be replaced.
Option list:
|
Find What (-- for Mising Value) | find |
Input double |
|
Combined with the operator selected for the Condition variable, the value of this variable defines the condition used to find the values to be replaced. "--" stands for missing value here. |
Replace With | replace |
Input double |
|
Specifies the new value with which all the found cells will be replaced. |
Absolute Error | abs_error |
Input double |
|
Specifies the tolerance used to find the matrix data to be replaced. If the absolute difference between two values is less than the tolerance, these two values will be regarded as equal values. This is disabled when Condition is > or < or <>. |
Use Absolute Value in Condition | use_abs |
Input int |
|
Specify whether or not to use the absolute values of the matrix data to test the given condition. |
Keep Sign if Condition True | keep_sign |
Input int |
|
Specify whether to keep the sign of the original value if the condition is true and the matrix data is replaced. |
Set as Missing if Condition False | set_missing |
Input int |
|
Specify whether or not to assign missing values to the cells whose original values do not meet the condition. |
Look In | lookin |
Input int |
|
Specify the scope to search and replace.
Option list:
|
Output Matrix | om |
Output MatrixObject |
|
Specify the destination of output matrix.
See the syntax here. |
This X-Function is capable of finding and replacing data in matrix cells.
This example shows you how to replace values that are less than 1000 with 1000 in the active matrix.
mreplace -d;
in the command window to bring up the mreplace dialog box.