自己时常花费较多时间用于寻找及回忆命令上,不应该,因此做些记录,更快的恢复记忆。
% read the whole files
patient_paths='patient_paths';
patient_names=dir(patient_paths);
for ii=3:length(patient_names) % start from 3
patient_name=patient_names(ii).name;
patient_path=fullfile(patient_paths,patient_name);
% read the files end with '.nii'
patient_paths='patient_paths';
patient_names=dir([patient_paths, '/*.nii']); % careful! / for Lunix and \ for windows
for ii=1:length(patient_names) % start from 1
patient_name=patient_names(ii).name;
patient_path=fullfile(patient_paths,patient_name);
另一种方法,写法更简洁,自己用的少,可以学习下:
dirs = dir([path, '/*.nii']); % careful! / for Lunix and \ for windows
dircell = struct2cell(dirs)';
names = dircell(:,1);
至此,以后不应在matlab读取文件上浪费时间,如有更好方法,随时更新。
读取文件夹:
function SubFolders = A6_GetSubFolders(ParentFolder)
SubFolderNames = dir(ParentFolder);
SubFo

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



