Effacer les filtres
Effacer les filtres

switch in text file

1 vue (au cours des 30 derniers jours)
Daniela Correa
Daniela Correa le 5 Juin 2018
Commenté : Daniela Correa le 5 Juin 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

Réponse acceptée

Are Mjaavatten
Are Mjaavatten le 5 Juin 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
  1 commentaire
Daniela Correa
Daniela Correa le 5 Juin 2018
Thank you !!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by