필터 지우기
필터 지우기

load a file containing disorganized data

조회 수: 2 (최근 30일)
Alexandre Williot
Alexandre Williot 2015년 4월 24일
답변: Alexandre Williot 2015년 4월 28일
Hello,
I load a file containing disorganized data files and I would get the file number located at the end of the file name. Then have the file number in my final matrix. For that I apply this code
if strcmp(Fichiers_Travail2(1,end),1)==1
num_sujet = 1;
elseif strcmp(Fichiers_Travail2(1,end),2)==1
num_sujet = 2;
elseif strcmp(Fichiers_Travail2(1,end),3)==1
num_sujet = 3;
elseif strcmp(Fichiers_Travail2(1,end),4)==1
num_sujet = 4;
elseif strcmp(Fichiers_Travail2(1,end),5)==1
num_sujet = 5;
elseif strcmp(Fichiers_Travail2(1,end),6)==1
num_sujet = 6;
elseif strcmp(Fichiers_Travail2(1,end),7)==1
num_sujet = 7;
elseif strcmp(Fichiers_Travail2(1,end),8)==1
num_sujet = 8;
elseif strcmp(Fichiers_Travail2(1,end),9)==1
num_sujet = 9;
elseif strcmp(Fichiers_Travail2(1,end),10)==1
num_sujet = 10;
end
But I have this error message and I don't understand why because I used the same for another information and it works:
??? Undefined function or variable 'num_sujet'.

채택된 답변

Alexandre Williot
Alexandre Williot 2015년 4월 28일
Ok, this is what I needed: I just had to put the values into brackets and include the file extension in my calculation
if strcmp(Fichiers_Travail2(1,end-4),'1')==1
num_sujet = 1;
elseif strcmp(Fichiers_Travail2(1,end-4),'2')==1
num_sujet = 2;
elseif strcmp(Fichiers_Travail2(1,end-4),'3')==1
num_sujet = 3;
elseif strcmp(Fichiers_Travail2(1,end-4),'4')==1
num_sujet = 4;
elseif strcmp(Fichiers_Travail2(1,end-4),'5')==1
num_sujet = 5;
elseif strcmp(Fichiers_Travail2(1,end-4),'6')==1
num_sujet = 6;
elseif strcmp(Fichiers_Travail2(1,end-4),'7')==1
num_sujet = 7;
elseif strcmp(Fichiers_Travail2(1,end-4),'8')==1
num_sujet = 8;
elseif strcmp(Fichiers_Travail2(1,end-4),'9')==1
num_sujet = 9;
elseif strcmp(Fichiers_Travail2(1,end-5:end-4),'10');
num_sujet = 10;
else disp (Fichiers_Travail2)
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by