필터 지우기
필터 지우기

Flexible use of fullfile

조회 수: 1 (최근 30일)
Thang  Le
Thang Le 2014년 3월 5일
편집: per isakson 2018년 2월 22일
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!

채택된 답변

Walter Roberson
Walter Roberson 2014년 3월 5일
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
Thang  Le
Thang Le 2014년 3월 5일
This is great! I've just started using sprintf so this is a good lesson. Thank you so much, Walter.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by