samedi 4 novembre 2017

Matlab find array elements and replace column

I have a matrix A of size 13472x1537. This matrix contains values smaller than 1. In my case I seek for a solution to satisfy the following condition: If a column contains a value smaller than 1, replace all other values in the same column with NaN.

I was able to implement a code that could replace these values (smaller than 1) with the previous value (or any value). However, I am looking for a solution that changes every value in the column to "NaN" no matter whether later (or previous) values are greater than 1.

I have i=1537; t=13472

for i = 1:size(A,2) 
    I = A(1,i);
    for t= 2:size(A,1)
        if A(t,i) <= 1
           A(t,i) = I;
        else
        I = A(t,i);
        end
    end
end

Aucun commentaire:

Enregistrer un commentaire