There are a couple of commands that may do what you want, but I'm not sure if you can completely avoid the for loops (someone else may have a better idea). The ismember command (type help ismember) is described as:
LIA = ismember(A,B) for arrays A and B returns an array of the same
size as A containing true where the elements of A are in B and false
So you could do something like C(ismember(C(:,1),A),2) and that would return all the elements in the second column of C whose first column value is in A. Of course, this is not the same as your B (order is wrong and doesn't handle the duplicate 6 in A). But with a loop you could do something…
An alternative is to use the bsxfun command (type help bsxfun) which is described as:
bsxfun Binary Singleton Expansion Function
C = bsxfun(FUNC,A,B) applies the element-by-element binary operation
specified by the function handle FUNC to arrays A and B, with singleton
expansion enabled. FUNC can be one of the following built-in functions:
Try running Z=bsxfun(@eq,C(:,1),A') from the command window. (Note that A has been transposed.) It will return a matrix with the number of columns equal to the length of A and the number of rows equal to the number of rows in C. For any one column i, if the value is zero, then that row element does not match A(i). Else if the value is one, then that row element does match A(i). Note that C(Z(:,1),2) returns the first four elements of your vector B, C(Z(:,2),2) the next four elements, etc. So you could loop over Z to construct your B.
Either way, there is still (for this answer) one for loop.