我正在使用一个在循环中生成字符串集合的脚本:
'folder1/im1'
'folder1/im2'
...
'folder1/im3'
我将字符串分配给一个变量,当我尝试执行该img = dicomread(file);
函数时,我收到以下错误:
Error using dicomread>newDicomread (line 164)
The first input argument must be a filename or DICOM info struct.
Error in dicomread (line 80)
[X, map, alpha, overlays] = newDicomread(msgname, frames);
Error in time (line 14)
img = dicomread(file);
但是,使用命令行我没有收到错误:img = dicomread('folder1/im1')
.
代码如下:
for i=1:6 %six cases
nameDir = strcat('folder', int2str(i));
dirData = dir(nameDir);
dirIndex = [dirData.isdir];
fileList = {dirData(~dirIndex).name}; % list of files for each directory
n = size(fileList);
cd(nameDir);
for x = 1:n(2)
img = dicomread(strcat(pwd(), '/', fileList(x)));
end
cd('..');
end
可能是什么错误?