Seperate rows in matrix based on values of the elements.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mike Mierlo van
el 2 de Mzo. de 2020
Comentada: Mike Mierlo van
el 2 de Mzo. de 2020
Hi,
I have simplified my 'multiple radar' problem into this: Lets say I have matrix A, consisting of columns 1 (timestamp) and 2 (value). I want obtain matrices that have ascending timestamps and the difference between the values in column 2 of the new vectors must not be greater than 5.
%Input matrix [timestamp values]
A= [0 100;
0 400;
0 500;
1 103;
1 397;
1 502;
2 506;
2 104;
2 399];
%Now magic happens
%Output matrices per radar [timestamp values]
OUT1= [0 100;
1 103;
2 104];
OUT2= [0 400;
1 397;
2 399];
OUT3= [0 500;
1 502;
2 506];
Hopefully somebody can help me out of this misery
0 comentarios
Respuesta aceptada
KALYAN ACHARJYA
el 2 de Mzo. de 2020
Editada: KALYAN ACHARJYA
el 2 de Mzo. de 2020
for i=1:length(unique(A(:,1)))
mat{i}=A(A(:,1)==i-1,:);
end
result=cell2mat(mat)
out1=reshape(result(1,:),[2,3])' % Use loop for 3 statements
out2=reshape(result(2,:),[2,3])'
out3=reshape(result(3,:),[2,3])'
# This may be possible without loop also, recomended
6 comentarios
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!