How to use deblank() In MATLAB
The deblank() function is used to remove the trailing whitespace or tab characters and null characters from the specified string and returns the result without the trailing whitespace.
Syntax:
deblank(string)
Parameters: This function accepts a parameter which is illustrated below:
- string: This is the specified string with whitespace or tab characters.
Return values: It returns a new string without trailing whitespace or tab characters.
Example 1:
Matlab
% MATLAB code for space remove in string % using deblack() % Specifying a string 'gfg' % along with a tab and % whitespace character String = sprintf( '\t gfg \t' ); % Adding '|' character to the % above string [ '|' String '|' ] % Calling the deblack() over % above string to remove % tab and whitespace characters New_String = deblank(String); % Getting the specified string % without trailing tab and whitespace [ '|' New_String '|' ] |
Output:
ans = | gfg | ans = | gfg|
Example 2
Matlab
% MATLAB code for convert character array % into string then remove space % Specifying a character array with % space and tab character char = [ 'gfg' ; 'GFG ' ; 'w3wiki ' ]; % Converting the above character array into % string String = string(char); % Calling the deblank() over % above string to remove % tab and whitespace characters New_String = deblank(String) |
Output:
New_String = "gfg" "GFG" "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.
Contact Us