필터 지우기
필터 지우기

syntax help--creating file path

조회 수: 2 (최근 30일)
Victoria Klimaj
Victoria Klimaj 2013년 9월 26일
편집: Walter Roberson 2023년 12월 19일
Hi,
I am having trouble specifying a file path to a changing directory/set of files within a for loop. The path as it is now is below:
inputs{1, crun} = cellstr(spm_select('FPList'[allinput,'MOVr1',filesep,Order{crun,1}],'^raf.*\.img$'));
Along with possible bracket/parentheses issues, I am thinking the problem is with how to incorporate Order{crun,1}, which is the reference to the changing variable within the path. Order{crun,1} is supposed to refer to variables in the first column of a previously loaded file, Order.mat, which specifies a list of subject folders in the path. With this path, I am trying to switch the subject folder with each iteration of the loop based on the column of variables, but am not sure how to get that to work.
Any suggestions would be very appreciated!
Thanks,
Victoria

채택된 답변

dpb
dpb 2013년 9월 26일
inputs{1, crun} = cellstr(spm_select('FPList'[allinput,'MOVr1',filesep,Order{crun,1}],'^raf.*\.img$'));
No idea what you really want the name to be in the end (what's allinput ?) but assuming that the function (?) spm_select is expecting a qualified filename, sotoo
fn=fullfile(['FPList' allinput 'MOVr1'],[Order{crun,1}'^raf.*\.img$']);
inputs{1, crun} = cellstr(spm_select(fn));
may be at least on the right track assuming allinput is a character variable.
Play with the building of the qualified filename at the command line w/ the terms until it looks as expected with fixed input; then substitute variables into the expression to debug.
  댓글 수: 1
George Abrahams
George Abrahams 2023년 12월 19일
Hi Victoria, beyond this, as you're dynamically building paths with some complexity, it may also be an idea to check that they are valid before trying to use them. My isvalidpath function on File Exchange will handle that for you.

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

추가 답변 (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