Return the first and last characters of a character array - MATLAB Cody - MATLAB Central

Problem 649. Return the first and last characters of a character array

Difficulty:Rate
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

58.43% Correct | 41.57% Incorrect
Last Solution submitted on May 11, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Group

Project Euler II Image
Project Euler II
  • 12 Problems
  • 51 Finishers

Problem Recent Solvers10875

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page