Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我的Matlab代码有什么问题?索引越界_Matlab_Filter_Nmea_Kalman Filter - Fatal编程技术网

我的Matlab代码有什么问题?索引越界

我的Matlab代码有什么问题?索引越界,matlab,filter,nmea,kalman-filter,Matlab,Filter,Nmea,Kalman Filter,我正在尝试读取包含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))'; 过滤器 clear all A=textread('xxx\x.txt','%s','headerlines',1); for i=1:30; n=2*i-1

我正在尝试读取包含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))';
过滤器

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);
我不明白为什么它是错的

Longitude=c(:,28:36);%Extract Longitude Array

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

A
为空。改用:

>>fid=fopen('C:\Users\imf\Desktop\2.txt','rt'); >>A=文本扫描(fid,'%s'); >>A=A{1}; >>fclose(fid);
您删掉了字符串中错误的部分,并以开头的
,N,
部分结束(也没有小数)。我相信你想要

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

为了避免名称冲突,我会将您的脚本文件重命名为除
filter.m
之外的其他名称(有一个内置的MATLAB函数名)ya!我真傻!就这么想出来了!谢谢你们也在切断数据,我只能假设纬度部分是错的。你也应该仔细检查一下。
Longitude=c(:,31:42);%Extract Longitude Array