我有一个* .txt文件有多个记录,从连接到Arduino的MPU6050。
I have a single *.txt file with multiple records, from an MPU6050 connected to Arduino.
我可以识别何时创建新记录,因为列时间从随机值重新开始,而不是以前的(从不0)。
I can recognize when a new record was made because the column time restart from a random value lower then the previous (is never 0).
该文件是一个nX7,它按照时间,ax,ay,az,gx,gy,gz
The file is a nX7 which contains in order time, ax, ay, az, gx, gy, gz
我试图从单个矩阵中提取m个子记录,所以我定义了一个逻辑if。
I am trying to extract the m subrecords from the single matrix, so i defined a logical if.
我有一个土木工程师的背景,我是一个与Matlab的noob。 感谢你的时间,谢谢你的耐心。
I have a civil engineer background and i am a noob with Matlab. Thanks for your time, thanks for you patience.
我试图用下面的代码解决这个问题,但我认为只是垃圾。
I tried to solve this with the code below, but I think is only rubbish.
%Open the file filename= uigetfile ('.txt'); fileID = fopen (filename); logmpu6050 =csvread(filename); fclose (fileID); n=length(logmpu6050); %Count every time i>i+1 where i is the i,1 element of my dataset for i=1:n-1 %Save the data of the i raw every time happens i>i+1 if logmpu6050(i,1)>logmpu6050(i+1,1); rangematrix(i,:)= logmpu6050(i,:); end end % Create a new sets of matrices from boundary values我还在堆栈上读了很多问题,但我没有找不到解决方案:
I also read a lot of questions on stack but i didn't find the solution:
MATLAB:提取矢量的第n个元素
提取大的Matlab数据集子集
MATLAB:提取矩阵的多个部分而不使用循环
MATLAB:定期提取元素
从MATLAB矩阵中提取数据,无需循环
如何通过MATLAB中的索引从大型矩阵中提取向量
如何使用Matlab中的条件提取矩阵的一部分
推荐答案您可以使用diff。
filename= uigetfile ('.txt'); fileID = fopen (filename); logmpu6050 =csvread(filename); fclose (fileID); n=length(logmpu6050); %Count every time i>i+1 where i is the i,1 element of my dataset rangematrix = logmpu6050(diff(logmpu6050(:,1)) > 0,:);更多推荐
如何创建一个子矩阵,从满足逻辑条件的矩阵中提取每个原始数据?
发布评论