【问题标题】:What is wrong with my Matlab code? Index out of bounds [closed]我的 Matlab 代码有什么问题?索引超出范围[关闭]
【发布时间】:2011-08-08 23:48:39
【问题描述】:

我正在尝试读取包含 nmea 字符串的文本文件!但我明白了

??? Attempted to access y(1); index out of bounds because numel(Longitude)=0.
Error in ==> filter at 16
Loc(:,i)=coordinates(x(i),y(i))';

过滤器.m

clear all
A=textread('xxx\x.txt','%s','headerlines',1);
 for i=1:30;
n=2*i-1;
A(i)=A(n);
end
b=A(1:30,:);
c=char(b);
x=c(:,17:24);
y=c(:,28:36);

我不知道为什么它是错的?!

【问题讨论】:

  • 为避免名称冲突,我会将您的脚本文件重命名为 filter.m 以外的其他名称(该名称有一个内置的 MATLAB 函数)

标签: matlab filter nmea kalman-filter


【解决方案1】:

你剪掉了字符串的错误部分,最后得到了开头的,N, 部分(也没有小数点)。我相信你想要

Longitude=c(:,31:42);%Extract Longitude Array

【讨论】:

  • 耶!我真蠢!刚刚想通了!谢谢!!
  • 您还切断了我只能认为纬度部分错误的数据。你也应该仔细检查一下。
【解决方案2】:
Longitude=c(:,28:36);%Extract Longitude Array

我的猜测是 c(:,28:36) 是空的,这意味着 A 也可能是空的。

【讨论】:

    【解决方案3】:

    A 为空。请改用TEXTSCAN

    >> fid = fopen('C:\Users\myself\Desktop\2.txt', 'rt'); >> A = textscan(fid, '%s'); >> A = A{1}; >> fclose(fid);

    【讨论】:

      猜你喜欢
      • 2015-09-10
      • 1970-01-01
      • 1970-01-01
      • 2013-05-18
      • 1970-01-01
      • 1970-01-01
      • 2020-01-29
      • 1970-01-01
      • 2018-09-12
      相关资源
      最近更新 更多