It would be helpful if you posted what you have attempted and any errors. I'm not sure if I've grasped what you're trying to. Does this help?
m = 5; matrix = [[1 20 3 4 1]' [1 1 10 2 1]']; % for example
for i = 1 : m if matrix(i,1) == 1 & matrix(i,2) == 1 matrix(i,3) = matrix(i,1) + matrix(i,2); else matrix(i,3) =nan(1); % What do you want to do if cols 1 and 2 don't equal 1? end end matrix
"Kumar" wrote in message <email@example.com>... > I'm new to Matlab programmin and this may look like a simple question. I have to add rows in matrix based on certain criteria. For example, if the values in column 1 is 1 and values in cloumn 2 is 1, then i have to add elements in colum 3 of all such rows. In the matrix, elemets in column 1 varies from 1-20 and elements in colum 2 varies from 1-10. the size of the matrix is m by 3.