switch in text file

2 ビュー (過去 30 日間)
Daniela Correa
Daniela Correa 2018 年 6 月 5 日
コメント済み: Daniela Correa 2018 年 6 月 5 日
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
  1 件のコメント
Daniela Correa
Daniela Correa 2018 年 6 月 5 日
Thank you !!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by