MATLAB: Reduce one for loop

efficiency issue

Hello, I have a bunch of code in which there are 2 for loops. I want to increase the speed and have just one for loop. here is the lines:
for i=1:length(bid)
for j=1:pidlastindex
if(bid(i)==pid(j))
C(i) = delay(j);
end
j=j+1;
end
i=i+1;
end
To do so I did :
for i=length (bid)
C(i)=delay(bid==pid(i))
end
But I get an error: In an assignment A(:)=:B, the number of elements in A and B must be the same.
Could any one tell me what is wrong here?
Also C in that loop changes the dimension on every loop iteration.
Thanks.

Best Answer

What if there are multiple locations that match the bid? What if there are no locations that match the bid? What if one of the values is 23.45 and the other value is 23.45+(4e-15) and you can't tell the difference because they both show up as 23.45 on the screen?