Introducing element * in sprintf()
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello
I am trying to introduce the element * to the function sprintf in MATLAB.
My code look like this
ss=sprintf('%s//Segments//Image_TrueColor_%d',Pathname,*)
I could set the code to read in the names of the files at the point of the unknow number name but is it possible just to introduce the * (select all) command ?
Thank you in advance
0 comentarios
Respuestas (1)
Walter Roberson
el 19 de Jul. de 2012
That is not really a question about sprintf(), that is a question about the routine that you are using the resulting string. sprintf() just does string creation based upon the parameters passed to it, and it has no knowledge of files.
prefix = fullfile(Pathname, 'Segments');
fileinfo = fullfile( prefix, 'Image_TrueColor_*' );
filenames = strcat( prefix, {fileinfo.name} );
The result would be cell array of strings, one (complete) file name per entry.
For most operations you would then need to loop over those file names. Very few of the routines can operate on multiple files at the same time.
2 comentarios
Walter Roberson
el 19 de Jul. de 2012
Sorry, should have been
fileinfo = dir( fullfile( prefix, 'Image_TrueColor_*' ) );
Ver también
Categorías
Más información sobre Characters and Strings 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!