switch in text file

1 次查看(过去 30 天)
Hello, I would like to make a switch to separate the the text files that have the phrase 'exp_sse2.c' from the anothers txt files that don't have this phrase.
And after I would like to save in differents pastes both.
for i = 1:length(save_finaldirs)
C = save_finaldirs(1,i)
cd(C{1,:}(1:end-9))
rawdata = importdata('error.txt') %%here I am importing all the text files
IndexC = strfind(C,'exp_sse2.c') %%here I am looking for my phrase inside the text files
Index = find(not(cellfun('isempty', IndexC)))
switch IndexC %%here it's not working, I dont know to separate the files that have this phrase from the anothers and save it
case isempty
disp(1)
end
end

采纳的回答

Are Mjaavatten
Are Mjaavatten 2018-6-5
I think a simple if ... else would be better that switch in your case:
if isempty(strfind(C,'exp_sse2.c'))
% Actions for files not containing the string
else
% Actions for files containing the string
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by