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

44.34% Correct | 55.66% Incorrect
Last Solution submitted on Nov 12, 2025

Problem Comments

Solution Comments

Show comments
Join Cody Contest 2025 — Have Fun and Win Prizes!
...
We’re excited to invite you to Cody Contest 2025! 🎉 Pick a team,...
🚀 MATLAB EXPO 2025 – Day 2 Starts Tomorrow, November 13!
Don’t miss out on two incredible keynotes that will shape the future...
0

Problem Recent Solvers1974

Suggested Problems

More from this Author1

Problem Tags

Community Treasure Hunt

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

Start Hunting!