matlab出租车程序,MATLAB用出租车GPS数据分析深圳道路交通情况源代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
matlab出租车程序,MATLAB⽤出租车GPS数据分析深圳道路
交通情况源代码
%统计满⾜条件的车辆数
%tongji.m
%求车某时间段车得位置,即位于哪个分区
%7点到9点
%weizhi79.m
format short
clear
clc
[filename pathname index]=uigetfile('.txt','请选择结果⽂件','','MultiSelect','on');
if index
if iscell(filename)
len=length(filename);
res=[];col_title=cell(1,len);
qishi1=[];
l=0;
for i=1:len
qishi=[];jieshu=[];
fid=fopen([pathname filename{i}]);
col_title{i}=strtok(filename{i},'.txt');
[val pos]=textscan(fid,'%s%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%f%f%f%f%f','headerLines',1,'Delimiter',','); if length(find(cell2mat(val(:,22))>2))==0
l=l+1;
riqi11=cell2mat(val(:,11));riqi1=riqi11-49+1; %⽇期
riqi12=cell2mat(val(:,12));riqi2=riqi12-49+1;
riqi13=cell2mat(val(:,13));riqi3=riqi13-49+1;
hour=10*riqi2+riqi3; %时
riqi15=cell2mat(val(:,15));riqi4=riqi15-49+1;
riqi16=cell2mat(val(:,16));riqi5=riqi16-49+1;
fen=riqi4*10+riqi5; %分
n=length(hour);
aaa=cell2mat(val(:,20:21)); %第⼀列为经度,第⼆列为纬度
% a1=cell2mat(val(:,1));
for j=1:n-1
if riqi1(j)==3 %对应改riqi1,星期六
if hour(j)==7&fen(j)>=0&fen(j)<=10 %对应改上下班
% chepai1=[chepai1;a1];
qishi=[qishi;aaa(j,:)];
end
end
end
end
if length(qishi)~=0
qishi1=[qishi1;qishi(1,:)];
end
fclose(fid);
i
end
end
end
%距离
%起始
[n1,n2]=size(qishi1);
for i=1:n1
a1=sqrt((qishi1(i,1)-113.9333)^2+(qishi1(i,2)-22.5338)^2); %与分区⼀的距离a2=sqrt((qishi1(i,1)-114.1164)^2+(qishi1(i,2)-22.5649)^2);
a3=sqrt((qishi1(i,1)-114.3222)^2+(qishi1(i,2)-22.6343)^2);
a4=sqrt((qishi1(i,1)-114.0418)^2+(qishi1(i,2)-22.6431)^2);
a5=sqrt((qishi1(i,1)-114.2457)^2+(qishi1(i,2)-22.7228)^2);
a6=sqrt((qishi1(i,1)-114.0522)^2+(qishi1(i,2)-22.5398)^2);
a7=sqrt((qishi1(i,1)-113.9091)^2+(qishi1(i,2)-22.7242)^2);
a8=sqrt((qishi1(i,1)-113.8698)^2+(qishi1(i,2)-22.5907)^2);
aa=[a1 a2 a3 a4 a5 a6 a7 a8];
[v,d1]=min(aa);
qishi1(i,n2+1)=d1;
end
%结束
bb=qishi1(find(qishi1(:,n2+1)==6),:); %六区车辆信息
[n3,n4]=size(bb);
R1=0.0234;R2=0.0378;
for i=1:n3
bbb=sqrt((bb(i,1)-114.0522)^2+(bb(i,2)-22.5398)^2); %距中⼼点的距离if bbb<=R1
bb(i,n4+1)=1; %1为最内圆
elseif bbb<=R2
bb(i,n4+1)=2;
else
bb(i,n4+1)=3;
end
end
bbb1=bb(find(bb(:,n4+1)==1),:);。