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),:);

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值