How to use erase() In MATLAB
The erase(string, match) function is used to remove all occurrences of the specified match in the given string and returns the remaining text.
Syntax:
erase(string, match)
Parameters: This function accepts two parameters, which are illustrated below:
- string: This is the specified string from which the match is going to be removed.
- match: This is the specified match.
Return values: It returns a new string as the remaining text without the matching part.
Example 1:
Matlab
% MATLAB code for space removal % in string using erase() % Initializing a string array A = [ "gfg - GFG" ] % Calling the erase() function % over the above string array B = erase(A, " " ) |
Output:
A = gfg - GFG B = gfg-GFG
How to remove space in a string in MATLAB?
In this article, we are going to discuss how to remove space from a string in MATLAB with the help of isspace(), find(), strrep(), and regexprep() functions.