MATLAB: How can I delete the matching rows of two matrices

matching and deleting the rows of matrixMATLAB

Hello,
If I have a matrix R = [1 2 3; 4 5 6; 7 8 9; 10 11 12] and another matrix C= [ 1 2 3; 4 5 6] I want to create another matrix which is called B. The value of B is the rest of not matching rows between R and C so B should be B[ 7 8 9; 10 11 12]
I made two for loops but it doesn´t work
for i=1:length(R)
for j=1:length(C)
if C(j,3)==R(i,3)
R(i,:)=[]
end
end
end
Thanks

Best Answer

B = setdiff(R,C,'rows')