Your explanation is vague but I assume that you want to extract the non-zero (or positive) elements from a matrix, do some operations in these elements, and push back them into the original matrix. Then I suggest,
MyMatrix = (rand(5)>0.5).*rand(5);
[n,m,Positive_vector] = find(MyMatrix);
k = sub2ind(size(MyMatrix),n,m);
MyMatrix(k) = Positive_vector*2;
First line is for generating a random matrix with some zeros. Second line is to find the non-zero element of the matrix. If you just want the positive element, then you can modify it to find(MyMatrix > 0)
. Here, n and m are the sets of row and column numbers of non-zero elements, but I make that into a 1D indices in the third line. Fourth line is to apply some operation (this case multiply by 2) to the extracted vector and push back to the original places in the original matrix.
I assume that you do more complicated operation than multiplying the non-zero elements by 2. Otherwise you can do something like this...
MyMatrix = MyMatrix - (MyMatrix>0).*MyMatrix + (MyMatrix>0).*(MyMatrix)*2