Borrar filtros
Borrar filtros

Flexible use of fullfile

1 visualización (últimos 30 días)
Thang  Le
Thang Le el 5 de Mzo. de 2014
Editada: per isakson el 22 de Feb. de 2018
Hi,
I have the following line in my script:
roi = spm_select('FPList', fullfile(roi_path), '^RA.*\.mat$');
Depending on the type of image I want to process, sometimes I need to replace RA with either S4RA, S6RA, S8RA etc. In the earlier part of my script, I have an input called Configuration (e.g., Configuration = 'RA'). I intend to use this input to change the type of image when necessary. Could anyone tell me how to work Configuration into the line of script above so that when I change the configuration to say, S4RA, the line above will change accordingly from RA to S4RA without my having to do it manually? I hope this is clear. Thank you!

Respuesta aceptada

Walter Roberson
Walter Roberson el 5 de Mzo. de 2014
roi = spm_select('FPList', fullfile(roi_path), ['^' Configuration '.*\.mat$']);
or
roi = spm_select('FPList', fullfile(roi_path), sprintf('^%s.*\\.mat$', Configuration));
Notice the change from \. to \\. when using sprintf.
  1 comentario
Thang  Le
Thang Le el 5 de Mzo. de 2014
This is great! I've just started using sprintf so this is a good lesson. Thank you so much, Walter.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by