Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Problem 1951. Better Index Number

Created by Shaun VanWeelden

Let's say you want to save many, many files and append these files with a certain sortable index number. As you probably know, you often get in a situation where your files go like this:


Which is not ideal when you want your files to go like this:


So let's make a function that given the current index number and the maximum index number, it will return a string with leading 0's so that any computer will know how to sort the files. For example, if I were on index 9 and there were a total of 230 files, my function would return '009' so I could append that to my file.


Problem Group

Solution Statistics

42 correct solutions 12 incorrect solutions
Last solution submitted on Nov 28, 2015

Solution Comments