I think the immage can describe easily my problem.
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 defined, thanks to stack, my B matrix, where are stored all the boundary values (FXM in my pic)
I am trying to extract the F-1 submatrices from the single matrix, but each submatrix has different row, that depends from the length of the time record (A-B number of rows is different from B-C, but they have the same number of columns)
I have studied the "Submatrix" function, but i don't know how to apply in my specific situation, and i am not pratical with "Indexing" but i am studing how it works
Here the code i wrote
%Open the file
filename= uigetfile ('.txt');
fileID = fopen (filename);
logmpu6050 =csvread(filename);
fclose (fileID);
n=length(logmpu6050);
%Save the position of every i raw every time happens time(i)>time(i+1)
rangematrix = logmpu6050(diff(logmpu6050(:,1)) < 0,:);
%The last value sampled is exctracted from the dataset, because the last value don't satisfy the condition t(i)>t(i+1)
%but is still a boundary value
endlog=logmpu6050(end,:);
%We need to take the last
rangematrix = cat(1,rangematrix,endlog)
lengthrangematrix = length(rangematrix);
Here is were i am stuck
for i = 1: lengthrangematrix-1
submat(i)= submatrix(logmpu6050[rangematrix(i),:]);
Thanks, always, for your time.
I also read this question and documentation, but i still not able to find the solution :/
Matrix Indexing Create Function Handle
MATLAB: Extract multiple parts of a matrix without using loops
Aucun commentaire:
Enregistrer un commentaire