How to Replace Symbols With Text in MATLAB
MATLAB, the computing environment and programming language used by scientists, engineers and forensic investigators for algorithm development and data analysis, allows you to replace symbols with text or text characters using either the workspace browser or by executing a search function. The workspace browser makes it possible for you to replace symbols with characters when the symbol was a placeholder for a variable, while the function will replace all incidents of that symbol with characters within substrings in the code of the application or program written in MATLAB.
Instructions
-
Using the Workspace Browser
-
1
Open MATLAB, and then click “Desktop.” From the desktop, click “Workspace.”
-
2
Select the variable or table that contains the variable that needs to be changed. If the variable appears in all the tables, click “Ctrl” and “A” simultaneously to select all the variables in all tables.
-
-
3
Click the symbol to be replaced and then type the new character. This replaces the symbol with the character in all instances of that variable. Click "Enter" to finish.
Using the Function
-
4
Open the file containing the substrings that need to be changed.
-
5
Type in the following command to run the “strrep” function: "modifiedStr = strrep(origStr, oldSubstr, newSubstr)", without quotation marks.
For example, you may want to replace the symbols "+++" with the text “Hello” in a string called “characters,” such as "characters = 'I said +++.';". For this, you need to type the following command: "new_characters = strrep(characters, '+++', 'Hello')". -
6
Hit or type “Run” to execute the function.
-
1