MATLAB: How to select specific matrix rows trough specifik given numbers

MATLABmatrixrowoperations

Hey guys. Im working on a project where i have i to pick out specific rows in one N x 6 matrix matching a specifik given value.
Then using the placement of those specific rows in order to calculate data within those specific rows in a different N x 4 matrix.
The rows within the N x 6 matrix is combined like: [ year , month , day , hour , minute , second ]
So for an example i need to find all rows with the hour 15, i find two rows in that specific dataset one in row 4 and one in 10. I then need to calculate the exact same rows within the N x 4 matrix.
Any ideas to how this is done?
i've tried out with A(: , 4==15) but that doesn't tell the sepcific rownumber.

Best Answer

Try this:
% Determine which rows to extract:
rowsToSelect = A(:, 4) == 15;
% Make a new matrix with only those rows extracted:
extractedRows = A(rowsToSelect, :);