matlab - 从单元格中绘制数据
问题描述
我在(1x2)数据单元内有多个地理点数据。如何在 MATLAB 中将所有这些数据绘制到一张地图上?
我之前尝试过追加,但显然这不是我想要的。我真的想了解最好的方法。
clear;
clc;
% Specify folder where the files live
myFolder = 'C:\Users\J87662\Desktop\GPX Data Files';
% Check to make sure folder exists. Warns user if doesn't.
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
% Get a list of all files in the folder with the desired file name pattern.
theFiles = dir(fullfile(myFolder, '*.gpx')); % Using .gpx as the desired file type.
% Number of files in the folder
n = numel(theFiles);
data = cell(1,n);
for k=1:n
% Read each file
data{k} = gpxread(fullfile( myFolder, theFiles(k).name ));
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
end
尝试使用 data(1,1).Latitude 时,我收到错误“来自非结构数组对象的结构内容引用”。
解决方案
对元胞数组进行索引需要使用 {} 而不是 ()。请尝试使用 data{1, 1}.Latitude (因为您只有一列,所以 data{1}.Latitude 也应该可以使用)。
推荐阅读
- autohotkey - 如何改变循环?
- javascript - 添加、删除、更新记录到数据库后的最佳实践
- go - 为什么当阻塞读取连接关闭时,这个 goroutine 随机无法退出?
- hibernate - Hibernate:本机查询无法处理用单引号括起来的值
- kubernetes - 无法从 ansible 运行 kubectl
- mysql - 如何在一行中添加三个不同表中的三个数字mysql phpmyadmin
- python - Geopandas 不工作。我无法绘制图表
- swift - Cocoapods-Deintegrate from project 导致 SIGABRT 错误
- python - Django 中的并发进程日志
- azure - 如何使用空白登录 url 创建企业图库应用程序以启用 IdP 发起的流程?