Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 124528

Submitted on 6 Aug 2012 by Noah

Correct

10Size
Leading solution size is 10.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
cstr = {'     Trim leading white-space';
        'Trim trailing white-space     '};
y_correct = {'Trim leading white-space';'Trim trailing white-space'};
assert(isequal(white_space_remove(cstr),y_correct))
ans =
    'Trim leading white-space'
    'Trim trailing white-space'
2
Pass
 
%%
 NL = char(0);
TAB = char(9);
x = [NL 32 TAB NL 'AB' 32 NL 'CD' NL 32 TAB NL 32];
y_correct = [NL 32 TAB NL 'AB' 32 NL 'CD' NL 32 TAB NL];
assert(isequal(white_space_remove(x),y_correct))
ans =
  	 AB  CD