mercredi 2 décembre 2015

Vectorize nested for-loop and if statement

i'm trying to vectorize the following nested loop, so I don't have to plot the values in a loop:

for i=1:size(validMaskX,1)
   for j=1:size(validMaskX,2)
      if( validMaskX(i,j) )
         plot(ah, [dataX(i,j) dataX(i,j+1)], [dataY(i,j) dataY(i,j+1)], 'g-')               
      end
    end
 end

  • size(validMaskX) = 45x44
  • size(dataX)=size(dataY)=45x45

Any suggestions on how to do this?

Aucun commentaire:

Enregistrer un commentaire