2.2.2.9 mreplace

Menu Information

Edit: Replace

Brief Information

Find and replace values in matrix using conditions

Command Line Usage

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

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Matrix Object im

Input/Output

MatrixObject

<active>
Specify Input matrix.
Condition cond

Input

int

0
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:

  • eq:Cell(i,j)=
    Find data that is equal to the Find What value.
  • lt:Cell(i,j)<
    Find data that is less than the Find What value.
  • le:Cell(i,j)<=
    Find data that is not greater than the Find What value.
  • gt:Cell(i,j)>
    Find data that is greater than the Find What value.
  • ge:Cell(i,j)>=
    Find data that is not less than the Find What value.
  • ne:Cell(i,j)<>
    Find data that is not equal to the Find What value.
Find What (-- for Mising Value) find

Input

double

<unassigned>
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

<unassigned>
Specifies the new value with which all the found cells will be replaced.
Absolute Error abs_error

Input

double

0.01
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

0
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

0
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

0
Specify whether or not to assign missing values to the cells whose original values do not meet the condition.
Look In lookin

Input

int

7
Specify the scope to search and replace.

Option list:

  • active_object:Active MatrixObject
    The active matrix object.
  • active_sheet:Active Matrixsheet
    The active matrixsheet.
  • active_book:Active Matrixbook
    The active matrixbook.
  • all_in_active_folder:All Matrixbooks in Active Folder
    All of the matrixbooks in the active folder (those is subfolders are not included).
  • recursive_in_active_folder:All Matrixbooks in Active Folder (Resursive)
    All of the matrixbooks in the active folder and its subfolders.
  • open_in_active_folder:All Matrixbooks in Active Folder (Open)
    All of the non-hidden matrixbooks in the active folder (those is subfolders are not included).
  • all_in_project:All Matrixbooks in Project
    All of the matrixbooks in the project.
  • specified:Specified MatrixObject
    The specified matrixobject.
Output Matrix om

Output

MatrixObject

<input>
Specify the destination of output matrix.

See the syntax here.

Description

This X-Function is capable of finding and replacing data in matrix cells.

Examples

This example shows you how to replace values that are less than 1000 with 1000 in the active matrix.

  1. Create a new project. Then create a new matrix and activate it.
  2. Import the file <Origin Program Directory>\Samples\Graphing\3D Surface & Contour.dat.
  3. Enter mreplace -d; in the command window to bring up the mreplace dialog box.
  4. Set Condition to Cell(i,j)<, Find What and Replace With both are 1000. The Output Matrix should be <new>. Keep other settings as they are.
    Mreplace 1.png
  5. Click the OK button. Then all the values that are less than 1000 will be replaced with 1000.

Related X-Functions

wreplace