switch in text file

1 view (last 30 days)
Daniela Correa
Daniela Correa on 5 Jun 2018
Commented: Daniela Correa on 5 Jun 2018
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

Accepted Answer

Are Mjaavatten
Are Mjaavatten on 5 Jun 2018
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

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!