Problem 1461. Duplicate a character
Duplicate a character 'n' times.
Example 1: str='a' n=5
output='aaaaa'
Example 2: str='*' n=3
output='***'
Solution Stats
Problem Comments
-
2 Comments
Mineralter
on 28 Apr 2013
n is a nonnegative interger.may it be the largest problem that i meet.
Björn
on 5 Dec 2015
My initial solution with repelem(str,n) for n=0 creates a size 1x0 char class but suite only allows for a 0x0 class. Not sure why the difference would matter.
Solution Comments
Show commentsProblem Recent Solvers231
Suggested Problems
-
3371 Solvers
-
Replace NaNs with the number that appears to its left in the row.
2977 Solvers
-
Increment a number, given its digits
650 Solvers
-
Output any real number that is neither positive nor negative
393 Solvers
-
Back to Basics - Find no. of elements in a matrix?
304 Solvers
More from this Author9
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!