Return the first and last characters of a character array, concatenated together. If there is only one character in the character array, the function should give that character back twice since it is both the first and last character of the character array.
Example:
stringfirstandlast('boring example') = 'be'
Solution Stats
Problem Comments
4 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers12271
Suggested Problems
-
Replace NaNs with the number that appears to its left in the row.
3069 Solvers
-
We love vectorized solutions. Problem 1 : remove the row average.
894 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
1277 Solvers
-
11868 Solvers
-
667 Solvers
More from this Author56
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
There is a difference between string and char array since R2016b. Before that they could be used interchangeably, but now that is no longer true (although I believe some doc pages are still not careful about this).
The title and description have been updated, along with a few new test cases.
Wow this actually is such a great question
good problem