MATLAB: Removing data from corresponding column

deleting removing data from corresponding column

I have two columns of length 13304×1, and want to plot these against eachother with scatter. However i only want the values below 5 of column A, how can I delete the exact corresponding values of column B? Lets say column A is 11000×1 after deleting values >5, then its tempting to just remove the last 2304 rows of B, but this ruins the correspondance.

Best Answer

mask = A < 5;
A_selected = A(mask);
B_selected = B(mask);
scatter(A_selected, B_selected)