列车运行图MATLAB程序

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

%第一个%设6:42时间为0时刻,转换如下。a1=[6777777889999910101010101011111212121213131414151515161616161717171718181818192021];b1=[420102233405215301217222740510152845503343713344351825436404501835573193237212364222476];c1=7*ones(1,length(a1));d1=60*(a1-c1)+b1+18;e1=[7778888899910101010101111111112121212131313141515151616161617171818181818191919202121];f1=[23415831528375611535810152146513926311424485415244615624472126485923380713184301730173547];g=7*ones(1,length(a1));h1=60*(e1-g)+f1+18;%输入经历时间,求众数,得到一个差值矩阵f。x1=[414148414248454141414148484141414841414141414141414141574141414141484148415748414141484148554841]';v1=mode(x1)j1=x1-v1;disp(j1)%矩阵剔除,将f中大于0的用0代替得以矩阵m,将f小于0的数代替得一矩阵n,n,m都是1*20的矩阵。n1=(j1+abs(j1))/2;m1=j1;m1(find(j10))=0;%选取可行列车z1=zeros(1,d1(end)-d1(1)+1);%(或zeros(1,d(end)-d(1)))y11=d1(1):1:d1(end);fork=1:length(x1)-1fori=1:d1(end)-d1(1)+1ifd1(k+1)-y11(i)+m1(k+1)=5&&y11(i)-d1(k)-n1(k)=5;z1(i)=y11(i);endendend%将满足条件的列车再进行剔除,求数量最大且满足条件的列车r=0;g=0;k=1;p=1;l1=zeros(1,length(d1)+50);t1=zeros(1,d1(end)-d1(1)+1);fori=1:d1(end)-d1(1)ifz1(i)+1==z1(i+1)k=k+1;endifz1(i)z1(i+1)r=floor((k-1)/5)+1;foru=1:rg=i-k+1+5*(u-1);ifgd1(end)-d1(1)+1g=d1(end)-d1(1)+1;endl1(g)=z1(g);endk=1;endendl1(find(l1==0))=[];%找到l中0的位置,并令其为空,即删除w1=l1+v1;y13=0.1*ones(1,length(l1));y14=41*ones(1,length(w1));fori=1:length(l1)plot([l1(i),w1(i)],[y13(i),y14(i)]);holdonendy11=0.1*ones(1,length(d1));y12=41*ones(1,length(h1));fori=1:length(d1)plot([d1(i),h1(i)],[y11(i),y12(i)]);holdonend%第二个%设6:42时间为0时刻,转换如下。a2=[88810101011131415161920];b2=[644580245316322358281919];c2=7*ones(1,length(a2));d2=60*(a2-c2)+b2+18;e2=[89910101111131416161920];f2=[2441618421134504316463737];g=7*ones(1,length(a2));h1=60*(e2-g)+f2+18;%输入经历时间,求众数,得到一个差值矩阵f。x2=[18201818181818182018181818]';v2=mode(x2)j2=x2-v2;disp(j2)%矩阵剔除,将f中大于0的用0代替得以矩阵m,将f小于0的数代替得一矩阵n,n,m都是1*20的矩阵。n2=(j2+abs(j2))/2;m2=j2;m2(find(j20))=0;%选取可行列车z2=zeros(1,d2(end)-d2(1)+1);%(或zeros(1,d(end)-d(1)))y21=d2(1):1:d2(end);fork=1:length(x2)-1fori=1:d2(end)-d2(1)+1ifd2(k+1)-y21(i)+m2(k+1)=5&&y21(i)-d2(k)-n2(k)=5;z2(i)=y21(i);endendend%将满足条件的列车再进行剔除,求数量最大且满足条件的列车r=0;g=0;k=1;p=1;l2=zeros(1,length(d2)+50);t2=zeros(1,d2(end)-d2(1)+1);fori=1:d2(end)-d2(1)ifz2(i)+1==z2(i+1)k=k+1;endifz2(i)z2(i+1)r=floor((k-1)/5)+1;foru=1:rg=i-k+1+5*(u-1);ifgd2(end)-d2(1)+1g=d2(end)-d2(1)+1;endl2(g)=z2(g);endk=1;endendl2(find(l2==0))=[];%找到l中0的位置,并令其为空,即删除w2=l2+v2;y23=41*ones(1,length(l2));y24=59*ones(1,length(w2));fori=1:length(l2)plot([l2(i),w2(i)],[y23(i),y24(i)]);holdonendy21=41*ones(1,length(d2));y22=59*ones(1,length(h1));fori=1:length(d2)plot([d2(i),h1(i)],[y21(i),y22(i)]);holdonend%第三个%设6:42时间为0时刻,转换如下。a3=[789910101111121314151616171819191920];b3=[502661820501336565252512848261010395839];c3=7*ones(1,length(a3));d3=60*(a3-c3)+b3+18;e3=[889910111111131415161617171819202021];f3=[13493141431336591915162151114933332212];g=7*ones(1,length(a3));h3=60*(e3-g)+f3+18;%输入经历时间,求众数,得到一个差值矩阵f。x3=[2323252323222323232324302322232323232323]';v3=mode(x3)j3=x3-v3;disp(j3)%矩阵剔除,将f中大于0的用0代替得以矩阵m,将f小于0的数代替得一矩阵n,n,m都是1*20的矩阵。n3=(j3+abs(j3))/2;m3=j3;m3(find(j30))=0;%选取可行列车z3=zeros(1,d3(end)-d3(1)+1);%(或zeros(1,d(end)-d(1)))y31=d3(1):1:d3(end);fork=1:length(x3)-1fori=1:d3(end)-d3(1)+1ifd3(k+1)-y31(i)+m3(k+1)=5&&y31(i)-d3(k)-n3(k)=5;z3(i)=y31(i);endendend%将满足条件的列车再进行剔除,求数量最大且满足条件的列车r=0;g=0;k=1;p=1;l3=zeros(1,length(d3)+50);t3=zeros(1,d3(end)-d3(1)+1);fori=1:d3(end)-d3(1)ifz3(i)+1==z3(i+1)k=k+1;endifz3(i)z3(i+1)r=floor((k-1)/5)+1;foru=1:rg=i-k+1+5*(u-1);ifgd3(end)-d3(1)+1g=d3(end)-d3(1)+1;endl3(g)=z3(g);endk=1;endendl3(find(l3==0))=[];%找到l中0的位置,并令其为空,即删除w3=l3+v3;y33=59*ones(1,length(l3));y34=82*ones(1,length(w3));fori=1:length(l3)plot([l3(i),w3(i)],[y33(i),y34(i)]);holdonendy31=59*ones(1,length(d3));y32=82*ones(1,length(h3));fori=1:length(d3)plot([d3(i),h3(i)],[y31(i),y32(i)]);holdonend%第四个%设6:42时间为0时刻,转换如下。a4=[78888899910101111111313131315151616161818192020];b4=[0021284857915255159163957213242567475245443642939];c4=7*ones(1,length(a4));d4=60*(a4-c4)+b4+18;e4=[788899991011111112121314141415161616171819202021];f4=[2727495616323742019274415254901024351533592931410377];g=7*ones(1,length(a4));h4=60*(e4-g)+f4+18;%输入经历时间,求众数,得到一个差值矩阵f。x4=[27272828283528273528282836282828282828282835352728282828]';v4=mode(x4)j4=x4-v4;disp(j4)%矩阵剔除,将f中大于0的用0代替得以矩阵m,将f小于0的数代替得一矩阵n,n,m都是1*20的矩阵。n4=(j4+abs(j4))/2;m4=j4;m4(find(j40))=0;%选取可行列车z4=zeros(1,d4(end)-d4(1)+1);%(或zeros(1,d(end)-d(1)))y41=d4(1):1:d4(end);fork=1:length(x4)-1fori=1:d4(end)-d4(1)+1ifd4(k+1)-y41(i)+m4(k+1)=5&&y41(i)-d4(k)-n4(k)=5;z4(i)=y41(i);endendend%将满足条件的列车再进行剔除,求数量最大且满足条件的列车r=0;g=0;k=1;p=1;l4=zeros(1,length(d4)+50);t4=zeros(1,d4(end)-d4(1)+1);fori=1:d4(end)-d4(1)ifz4(i)+1==z4(i+1)k=k+1;endifz4(i)z4(i+1)r=floor((k-1)/5)+1;foru=1:rg=i-k+1+5*(u-1);ifgd4(end)-d4(1)+1g=d4(end)-d4(1)+1;endl4(g)=z4(g);endk=1;endendl4(find(l4==0))=[];%找到l中0的位置,并令其为空,即删除w4=l4+v4;y43=82*ones(1,length(l4));y44=110*ones(1,length(w4));fori=1:length(l4)plot([l4(i),w4(i)],[y43(i),y44(i)]);holdonendy41=82*ones(1,length(d4));y42=110*ones(1,l

1 / 19
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功