File not found pass to next path
1 次查看(过去 30 天)
显示 更早的评论
For example :
path1 =char('C:\Users\Windows\Desktop\data base\H\');
path_user1 =char('user1_');
path_exp_1 =char('_h.fid');
path_procpar =char('\procpar');
path_amostra_user1=char('PA06F9ppt','PA06F13tr12','PAJ04100tr17','subs18','tr34','tr1619');
Do a
A=strcat(path1, path_user1, path_amostra_user1, path_exp_1)
To reach the path
C:\Users\Windows\Desktop\H\user1_SAMPLES_h.fid\procpar
So, A=<6x90 char>
Then I read the procpar files with for example a text scan
for i=1:6
TEXT(i,:)=textread(A(i,:),’%s’);
end
TEXT=<6x10 double>
In this case we have all the folders on my pc. If for example in the exp2 path_exp_2 =char('_hmbc.fid'); we don’t have all the folders sample only ‘PA06F9ppt' ,'PA06F13tr12'and 'PAJ04100tr17' When the textscan is going to find the path were the sample 'subs18','tr34', its give an error because in this experiment don’t have this path ??? Error using ==> textread at 167 File not found. How I can fix that and associate the name of the samples that’s exists to the values of that
0 个评论
采纳的回答
Titus Edelhofer
2011-7-3
Hi,
you can use
exist(path1, 'dir')
if a folder exists and
exist(A(i,1), 'file')
to test if the file exists.
Titus
0 个评论
更多回答(1 个)
Jan
2011-7-3
Creating a CHAR array pads the strings with spaces, such that all have the same length:
path_amostra_user1 = char('PA06F9ppt', 'PA06F13tr12', ...
'PAJ04100tr17', 'subs18', 'tr34', 'tr1619');
Now the line containing 'tr34' has 7 trailing spaces. But I assume the filename does not have these spaces. If this is the problem, use a cell string instead.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!