利用matlab mobile采集GPS数据进行可视化分析
Hello啊,GPS数据在交通大数据分析中起到了很大作用,。。。。。(不想写废话了,直接开始吧)
首先,需要在手机上下载matlab移动端,iOS和安卓系统都可以下,我刚开始学习matlab的时候用过,还算好用,需要申请账号什么的就不说了。
下载好之后,直接登录即可。
在传感器页面,就可以看到相应的采集页面,点击开始采集。当关闭后,进入MATHWORK官网个人账户(MATLAB Drive),可下载所采集到的内容。
另一种有效的方式是在命令行创建 mobiledev 对象,将产生一个采集器,开始采集,当采集结束后,关闭即可,原理相同,但采用这种方式,在移动端进行数据处理会方便很多。
m = mobiledev; % 启动传感器前创建 mobiledev 对象
m.Logging = 1; % 开始记录数据
m.PositionSensorEnabled = 1;
pause(1000) % 采集时长
m.Logging = 0; % 停止记录数据
得到的m为m是采集传感器数据的 mobiledev 对象的名称,matlab提供了各种在移动端处理所得数据的函数。
比较常用的函数 用法这里备注下,有需要可去官网自行查看。
[lat, lon, t, speed, course, alt, horizacc] = poslog(m) % 获取记录的纬度、经度、时间戳、速度、航向、海拔和水平精度位置数据[log, timestamp] = accellog(m) % 返回加速度日志
做了一个可视化工具:
这些数据处理过程将在PC端进行(暂时不知道移动端能不能运行)
首先,我们load一下前面所采集到的数据:
clc;clear
load sensorlog_20230608_171258.mat % 这个是2023年6月8日去学校外卖吃饭采集的数据hhh
由于笔者是做交通运行评价方面的,这里简单以自己研究方向做个可视化分析:
所导入的数据得到的是一个Table数据类型的变量,(之前采集只采集了位置信息,因为暂时只有位置信息对我有用)
我们对数据进行提取:
lat = cell2mat(table2cell(Position(:,'latitude')));
lon = cell2mat(table2cell(Position(:,'longitude')));
speed = cell2mat(table2cell(Position(:,'speed')));
对所得数据进行处理得到轨迹图形(篇幅有限,不对经纬度转距离的函数进行展示了,百度都有):
[n,~] = size(speed);
set_ao = [lat lon];
begin = set_ao(1,:);
dist = Dist(begin,set_ao);
time = [1:n]';sub1 = subplot(1,2,1);
plot(time,dist,'LineWidth',2)
xlabel('Time (s)')
ylabel('Distance (km)');
set(get(gca,'XLabel'),'FontSize',10);
sub2 = subplot(1,2,2);
plot(speed,dist,'-','LineWidth',2)
xlabel('V (m/s)')
set(get(gca,'XLabel'),'FontSize',10);
set(gca,'FontName','Times New Roman','FontSize',10)pos1 = [0.1,0.097619047619048,0.616071428571429,0.821299871299871];
pos2 = [0.715625,0.097619047619048,0.235785615528263,0.821299871299871];
set(sub2,'Position',pos2)
set(sub1,'Position',pos1)
set(gca,'ytick',[],'yticklabel',[])
sgtitle('Trajectory View on a Time-Space Diagram');
得到时空图如图:
下面我们在地图上将行驶轨迹展示出来:
%% 对速度值分 bin 以便使用离散数量的颜色来表示观测到的速度
nBins = 10;
binSpacing = (max(speed) - min(speed))/nBins;
binRanges = min(speed):binSpacing:max(speed)-binSpacing; % Add an inf to binRanges to enclose the values above the last bin.
binRanges(end+1) = inf;% |histc| determines which bin each speed value falls into.
[~, speedBins] = histc(speed, binRanges);lat = lat';
lon = lon';
speedBins = speedBins';% Create a geographical shape vector, which stores the line segments as
% features.
s = geoshape();
%% 为每个速度 bin 创建一个不连续线段。将为每个线段分配一种颜色。
for k = 1:nBins% Keep only the lat/lon values which match the current bin. Leave the % rest as NaN, which are interpreted as breaks in the line segments.latValid = nan(1, length(lat));latValid(speedBins==k) = lat(speedBins==k);lonValid = nan(1, length(lon));lonValid(speedBins==k) = lon(speedBins==k); % To make the path continuous despite being segmented into different% colors, the lat/lon values that occur after transitioning from the% current speed bin to another speed bin will need to be kept.transitions = [diff(speedBins) 0];insertionInd = find(speedBins==k & transitions~=0) + 1;% Preallocate space for and insert the extra lat/lon values.latSeg = zeros(1, length(latValid) + length(insertionInd));latSeg(insertionInd + (0:length(insertionInd)-1)) = lat(insertionInd);latSeg(~latSeg) = latValid;lonSeg = zeros(1, length(lonValid) + length(insertionInd));lonSeg(insertionInd + (0:length(insertionInd)-1)) = lon(insertionInd);lonSeg(~lonSeg) = lonValid;% Add the lat/lon segments to the geographic shape vector.s(k) = geoshape(latSeg, lonSeg);end
%% 使用 webmap 在浏览器中打开一个 Web 地图
wm = webmap('World Imagery');
%% 标记 位置
mwLat = 30.43932;
mwLon = 114.26154;
name = 'MathWorks';
iconDir = fullfile(matlabroot,'toolbox','matlab','icons');
iconFilename = fullfile(iconDir, 'wust.gif');
wmmarker(mwLat, mwLon, 'FeatureName', name, 'Icon', iconFilename);
%% 使用 autumn 颜色图生成与速度 bin 对应的颜色列表。这将为每个 bin 创建一个具有 RGB 值的 [nBins x 3] 矩阵
colors = autumn(nBins);
wmline(s, 'Color', colors, 'Width', 5);
%% 放大地图并聚焦于路线
wmzoom(17);
得到的实际轨迹图如图:
颜色越深表示我走的越慢。
很简单的小东西,希望对你有帮助。
利用matlab mobile采集GPS数据进行可视化分析相关推荐
- matlab segy文件,利用matlab实现segy格式数据的读写研究和分析.ppt
利用matlab实现segy格式数据的读写研究和分析 2.SEGY数据格式 地震数据一般以地震道为单位进行组织,采用SEG-Y文件格式存储.SEG-Y格式是由SEG (Society of Explo ...
- 利用Python对NBA SportUV数据进行可视化及分析
利用Python对NBA SportUV数据进行可视化及分析 SportUV是2005年,由以色列计算机科学家Gal Oz和Miky Tamir 创立的,其实,最早这两位大牛是搞导弹跟踪和高级光学识别 ...
- matlab抓取网页信息,如何利用Matlab抓取网页数据
如何利用Matlab抓取网页数据 2019-01-01 %朋友需要做金融方面的分析,要求从网站上下载大量的数据,一个一个复制粘贴太费事.我写了一个简单的网络爬虫,主要用到正则表达式,可以自动下载网页源 ...
- matlab如何取对数坐标,利用Matlab提取图片中曲线数据(线性修正,支持对数坐标)
利用Matlab提取图片中曲线数据 前一段时间看到一篇文章"利用Matlab提取图图片中的数据",觉得思路挺好,遂下载下来研究了一番,发现作者所编写的程序没有考虑原始图片非水平放置 ...
- 利用MATLAB批量读写tif数据(Landsat78)
利用MATLAB批量读写tif数据(Landsat7&8) 代码来源于:批量读写 代码如下: clc;clear %% 读取NDVI-tif文件 file_path_N = 'E:\';% 图 ...
- matlab物理实验数据处理,利用Matlab对物理实验数据进行处理
利用Matlab对物理实验数据进行处理 李凌云;王海军;韩之乃 [期刊名称]<南京晓庄学院学报> [年(卷),期]2005(021)005 [摘要]本文以热电偶的定标实验.二极管伏安特性实 ...
- 利用计算机及时采集检测数据,计算机的应用领域
计算机的应用领域 1. 计算机的应用领域 计算机的快速性.通用性.准确性和逻辑性等特点,使它不仅具有高速运算能力,而且还具有逻辑分析和逻辑判断能力.这不仅可以大大提高人们的工作效率,而且现代计算机还可 ...
- Python爬取天气数据及可视化分析!
来源丨Python之王 Python爬取天气数据及可视化分析 说在前面 天气预报我们每天都会关注,我们可以根据未来的天气增减衣物.安排出行,每天的气温.风速风向.相对湿度.空气质量等成为关注的焦点.本 ...
- Python爬取天气数据及可视化分析
Python爬取天气数据及可视化分析 文章目录 Python爬取天气数据及可视化分析 说在前面 1.数据获取 请求网站链接 提取有用信息 保存csv文件 2.可视化分析 当天温度变化曲线图 当天相对湿 ...
最新文章
- C#设计模式之:抽象工厂模式与反射
- div垂直水平居中经常使用的方法
- HTTP、TCP、UDP,Socket,HTTPS
- 测试用例 集成测试增删改查_20年高级测试人员的进阶汇总
- ubuntu安装postman
- CSS基础(part20)--CSS3结构伪类选择器
- R语言 plot()函数 基础用法
- c语言编程求连续几日的温差最大 最小值,数控维修理论题库(含答案)X2份..doc
- 获取选中_【字节】如何实现选中复制的功能
- LongAdder源码分析
- DXperience Winforms12.2版中文使用手册
- Error starting ApplicationContext. To display the conditions report re-run your application with ‘de
- bayer raw RGB raw
- 威富通 php,关于威富通的微信扫码支付处理思路和流程
- 鸿蒙方将腐皮雀跃而有,鸿蒙是谁:生于庄子,火于华为
- 开发嵌入式软件构建管道
- 计算机维修工程师认证,计算机维修工程师认证模拟试题.doc
- C++中atan()与atan2()的区别和用法
- 从零开始学习SEO的基础概念
- ZAM 3D 制作简单的3D字幕 流程(二)