Vectorize the digits of an Integer - MATLAB Cody - MATLAB Central

Problem 662. Vectorize the digits of an Integer

Difficulty:Rate

Create a vector of length N for an integer of N digits.

x = 123045;
x_vec = [1 2 3 0 4 5];

I happened upon a trick to do this.

I do not know why or how the trick works.

I'd like int2vec to be a standard conversion function

Solution Stats

60.53% Correct | 39.47% Incorrect
Last Solution submitted on Aug 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,...

Problem Recent Solvers328

Suggested Problems

More from this Author308

Problem Tags

Community Treasure Hunt

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

Start Hunting!