samedi 29 avril 2017

matlab vectorization if statement

Can someone please tell me the vectorized implementation of following matlab code. Predicted is an array containing either of the two values "pos" or "neg". I have to copy the values when condition comes true.

    p = 1;
    box = zeros(size(bbox));


   for k = 1: size(predicted)
        if predicted(k) == 'pos'
            box(p,:) = bbox(k,:);
            p = p + 1;
        end
   end

Aucun commentaire:

Enregistrer un commentaire