clc;
clear
fid=fopen('1.1 公汽线路信息.txt','r');
i=1;
while 1
tline=fgetl(fid);
if ~ischar(tline),break,end
if strcmp(tline,'')
continue
end
if strcmp(tline(1),'L')
str=tline;
continue
elseif strcmp(tline,'END')
break
end
if strcmp(tline,'单一票制1元。')
P=1;
continue
elseif strcmp(tline,'分段计价。')
P=2;
continue
end
if strcmp(tline(1:2),'上行')
L{i,1}=str;
L{i,2}=P;
L{i,3}='上行';
L{i,4}=tline(4:end);
i=i+1;
continue
elseif strcmp(tline(1:2),'下行')
L{i,1}=str;
L{i,2}=P;
L{i,3}='下行';
L{i,4}=tline(4:end);
i=i+1;
continue
elseif strcmp(tline(1:2),'环行')
L{i,1}=str;
L{i,2}=P;
L{i,3}='环行1';
L{i,4}=strcat(tline(4:end),tline(10:end));
i=i+1;
L{i,1}=str;
L{i,2}=P;
L{i,3}='环行2';
L{i,4}=strcat(tline(4:end),tline(10:end));
i=i+1;
continue
elseif strcmp(tline(1),'S')
L{i,1}=str;
L{i,2}=1;
L{i,3}='来回1';
L{i,4}=tline;
i=i+1;
L{i,1}=str;
L{i,2}=1;
L{i,3}='来回2';
L{i,4}=tline;
i=i+1;
continue
end
end
fclose(fid);
for i=1:size(L,1)
tline=L{i,4};
t=findstr(tline,'S');
temp=zeros(1,length(t));
if strcmp(L{i,3},'来回2')||strcmp(L{i,3},'环行2')
for j=length(t):-1:1
temp(length(t)-j+1)=str2double(tline(t(j)+1:t(j)+4));
end
else
for j=1:length(t)
temp(j)=str2double(tline(t(j)+1:t(j)+4));
end
end
L2{i,1}=temp;
end