I have a matrix in Matlab where each row looks something like this:
1 3 0.112 5.31275 4.61924 -6.50652
And I want to extract to different matrices according to the value presented in the first column. I know how to do this with for loops but I have too many points to leave this running for whatever time it will take to analyze everything. Is there an easier way to do this?
Here is my code with for loops:
accelerometer = 1;
gyroscope = 0;
a = 1;
g = 1;
for i = 1:size(raw,1)
if raw(i,1) == accelerometer
accelData(a,:) = raw(i,2:6);
a = a+1;
else
if raw(i,1) == gyroscope
gyroData(g,:) = raw(i,2:6);
g = g+1;
end
end
end
Thanks!