Removing whitespace characters, MATLAB in Engineering

Removing Whitespace Characters:

The MATLAB has functions which will eliminate trailing blanks from the end of a string and/or leading blanks from the starting of a string.

The deblank function will eliminate blank spaces from end of the string. For illustration, when few strings are padded in a string matrix so that all are of similar length, it is often preferred to then eliminate those extra blank spaces in order to actually use the string.

 

>> names = char('Sue', 'Cathy','Xavier')

names =

Sue

Cathy

Xavier

>> name1 = names(1,:)

name1 =

Sue

>> length(name1)

ans =

6

>> name1 = deblank(name1);

>> length(name1)

ans =

3

Posted Date: 10/20/2012 5:24:35 AM | Location : United States







Related Discussions:- Removing whitespace characters, Assignment Help, Ask Question on Removing whitespace characters, Get Answer, Expert's Help, Removing whitespace characters Discussions

Write discussion on Removing whitespace characters
Your posts are moderated
Related Questions
Text graphic function - Graphics objects: The text graphic function permits text to be printed in a Figure Window, involving special characters which are printed by using \spe

function imread: The function imread can read an image file, for illustration a JPEG (.jpg) file. The function reads color images into a 3-dimensional matrix. >> myimage1

Function issorted - set operations: The function issorted will return 1 for logical true when the argument is sorted in ascending order (minimum to maximum), or 0 for false wh

str2num function - String: The function str2num does the opposite; it takes the string in which a number is stored and converts it to the type double: >> num = str2num('123.

Illustration of Subfunctions: This is an illustration of running this program: >> rectarea Please enter the length: 6 Please enter the width: 3 For a rectan

Execute a exponential function program: Running the script will take up the menu as shown in the figure: Then, what happens will totally depend on which button(s) the

num2str function: The num2str function, that converts real numbers, can be called in many ways. If only the real number is passed to the num2str function, it will generate a s

Illustration of Preallocating a Vector: Illustration of calling the function: >> myveccumsum([5 9 4]) ans =     5  14  18 At the first time in the loop, outvec wil


Defined a variable in work space: The variables defined in the script will become a part of the workspace: >> clear >> who >> mysummfile    15 >> who