create a matrix from another matrix with only the entries in the third column that are positiv in matlab

You can create a new matrix by indexing the original matrix using the logical values of the condition that you specified:

main.m
% create original matrix
original_matrix = randi([-5 5], 5, 3)

% create new matrix with positive values from the third column
new_matrix = original_matrix(original_matrix(:,3)>0, 3)
183 chars
6 lines

This will return a new matrix with only the positive values from the third column of the original matrix.

related categories

gistlibby LogSnag