Why is this code wrong?

I have no idea what you are trying to do so can’t answer that question. All I’m saying is that the code snippet in your original post (maybe after some edits you made?) runs fine, in the sense that all rows in p get filled with the row in pdp which has the lowest value in the second column. I don’t know whether this is what you’re after though.

Overall your code seems very convoluted and unnecessarily complex, are you coming from Matlab by any chance?

3 Likes