首页 > 解决方案 > 从单元格中绘制数据

问题描述

我在(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 时,我收到错误“来自非结构数组对象的结构内容引用”。

标签: matlab

解决方案


对元胞数组进行索引需要使用 {} 而不是 ()。请尝试使用 data{1, 1}.Latitude (因为您只有一列,所以 data{1}.Latitude 也应该可以使用)。


推荐阅读