I have a single *.txt file with multiple records, from an MPU6050 connected to Arduino.
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).
The file is a nX7 which contains in order time, ax, ay, az, gx, gy, gz
I am trying to extract the m subrecords from the single matrix, so i defined a logical if.
- If time i > time i+1 keep track of the position from the original matrix and store in a submatrix (rangematrix) this boundary values.
- From the rangematrix create a set of submatrices (the total number of submatrices will be [size(rangematrix,1)-1] .
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: extract every nth element of vector
Extract large Matlab dataset subsets
MATLAB: Extract multiple parts of a matrix without using loops
MATLAB: Extracting elements periodically
Extract data from MATLAB matrix without for-loop
How to extract a vector from a large matrix by index in MATLAB?