matlab: simple matrix filtering - group size
Posted
by
Art
on Stack Overflow
See other posts from Stack Overflow
or by Art
Published on 2012-06-01T04:37:24Z
Indexed on
2012/06/01
4:40 UTC
Read the original article
Hit count: 170
I have a huuuge matrix storing information about X and Y coordinates of multiple particle trajectories , which in simplified version looks like that:
col 1- track number; col 2- frame number; col 2- coordinate X; col 3- coordinate Y
for example:
A =
1 1 5.14832 3.36128
1 2 5.02768 3.60944
1 3 4.85856 3.81616
1 4 5.17424 4.08384
2 1 2.02928 18.47536
2 2 2.064 18.5464
3 1 8.19648 5.31056
3 2 8.04848 5.33568
3 3 7.82016 5.29088
3 4 7.80464 5.31632
3 5 7.68256 5.4624
3 6 7.62592 5.572
Now I want to filter out trajectories shorter than lets say 2 and keep remaining stuff like (note renumbering of trajectories):
B =
1 1 5.14832 3.36128
1 2 5.02768 3.60944
1 3 4.85856 3.81616
1 4 5.17424 4.08384
2 1 8.19648 5.31056
2 2 8.04848 5.33568
2 3 7.82016 5.29088
2 4 7.80464 5.31632
2 5 7.68256 5.4624
2 6 7.62592 5.572
How to do it efficiently? I can think about some ideas using for loop and vertcat, but its the slowest solution ever :/
Thanks!
© Stack Overflow or respective owner