我有一个形式的矩阵:
m = 1, 0, 10, 20, 30, 40, 50;
2, 1, 11, 20, 30, 40, 50;
3, 0, 12, 20, 30, 40, 50;
4, 1, 12, 21, 30, 40, 50;
对于给定的列索引(比如 3)和行索引(比如 1),我想过滤掉该行中该列右侧具有相同值的所有行。使用上面的 m、columnIndex = 3 和 rowIndex = 1 的示例(用星号表示):
**
f(m, 3) = * 1, 0, 10, 20, 30, 40, 50; % [20, 30, 40, 50] matches itself, include
2, 1, 11, 20, 30, 40, 50; % [20, 30, 40, 50] matches the subvector in row 1, include
3, 0, 12, 20, 30, 40, 50; % [20, 30, 40, 50] matches the subvector in row 1, include
4, 1, 12, 21, 30, 40, 50; % [21, 30, 40, 50] does NOT match the subvector in row 1, filter this out
我怎样才能实现这种行为?我已经尝试过了,但我遇到了尺寸不匹配错误。
key = data( rowIndex, columnIndex:end );
filteredData = ( data( :, columnIndex:end ) == key );