str2double('00010001') or str2num('00010001') gives output as 10001 by ignoring the MSB '000' bits how to retain them?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I have some filenames which start with '0**' something like that (00010001,00010002,...00010010 etc), When I use str2double on that filename string str2double('00010001') it outputs 10001 without considering the MSB bits. Is there anyway I can get the filename as '00010001'?
Thanks, Gopi
2 comentarios
KSSV
el 14 de Mzo. de 2017
As it is a file name it's class will be char/ string. Why to use str2double?
Respuestas (1)
Akira Agata
el 14 de Mzo. de 2017
I think you want to generate a list of file names with serial number whose prefix is '0001'. If so, the following code will help. This generates the file name list from '00010001' with length of N.
N = 10;
list = strcat(repmat('0001',N,1),num2str((1:N)','%04d'));
3 comentarios
Jan
el 14 de Mzo. de 2017
See also:
for k = 1:10
FileName = sprintf('File%04d.ext', k)
end
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!