필터 지우기
필터 지우기

switch in text file

조회 수: 1 (최근 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 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