Split a string into chunks of specified length - MATLAB Cody - MATLAB Central

Problem 967. Split a string into chunks of specified length

Difficulty:Rate

Given a string and a vector of integers, break the string into chunks whose lengths are given by the elements of the vector. Extra characters leftover at the end should be dropped. Example:

break_string('I seem to be having tremendous difficulty with my lifestyle',[4 1 5 22])

should return a 4x1 cell array:

ans = 
  'I se'    'e'    'm to '    'be having tremendous d'

Solution Stats

45.16% Correct | 54.84% Incorrect
Last Solution submitted on May 08, 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

Basics on Vectors Image
Basics on Vectors
  • 11 Problems
  • 8183 Finishers

Problem Recent Solvers1919

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page