From: Vinh Le on 20 Mar 2010 14:01 I have 2 matrices with the same row, matrixA (n by k) and matrixB (n by 1) matrixA = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 matrixB = 1 2 2 1 2 now I would like to remove row of matrix A, based the value of element in matrix B For example remove all row of matrixA when value of element in matrixB is equal 2 matrixA = removeRow(matrixB) matrixA = 1 2 3 4 13 14 15 16 Only row 1 and row 4 of matrixA remained. The code I wrote as a mathlab script: ========================================== for i=1:length(matrixB) if matrix(1,i) = 2 index = index+1; removeRow(index) = i; end end matrixA(removeRow,:)=[] ========================================= It does not work ??? Index of element to remove exceeds matrix dimensions.
|
Pages: 1 Prev: Getting data from simulink model to display on GUI Next: gaussian pulse |