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 239778

Submitted on 3 May 2013 by James

Correct

26Size
Leading solution size is 12.
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
 
%%
str = 'b';n=5
y_correct = 'bbbbb';
assert(isequal(duplicate_char(str,n),y_correct))
n =
     5
ans =
     ''
ans =
bbbbb
2
Pass
 
%%
str = 's';n=1
y_correct = 's';
assert(isequal(duplicate_char(str,n),y_correct))
n =
     1
ans =
     ''
ans =
s
3
Pass
 
%%
str = 'b';n=10
y_correct = 'bbbbbbbbbb';
assert(isequal(duplicate_char(str,n),y_correct))
n =
    10
ans =
     ''
ans =
bbbbbbbbbb
4
Pass
 
%%
str = 'b';n=0
y_correct = '';
assert(isequal(duplicate_char(str,n),y_correct))
n =
     0
ans =
     ''
5
Pass
 
%%
str = '?';n=2
y_correct = '??';
assert(isequal(duplicate_char(str,n),y_correct))
n =
     2
ans =
     ''
ans =
??