How to use strrep() In MATLAB
The strrep() function is used to find and replace substrings. strrep(string1, string2, string3) is used to replace all occurrences of the string ‘string2’ within string ‘string1’ with the string ‘string3’.
Syntax:
strrep(string1, string2, string3)
Example:
Matlab
% MATLAB code for space removal in % string using strrep( ) % Initializing a string String = 'G e e k s f o r G e e k s' ; % Replacing space with null using the % strrep() function over the above string New_String = strrep(String, ' ' , '' ) |
Output:
New_String = w3wiki
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.