There are many sophisticated methods to do so. However, you can try with:
out = ssim(TestImage,refImage)
This computes the structural similarity index value for TestImage using refImage as the reference image.
out = 0, no matching out = 1, perfect matching So, you can convert the out value into percentage to find precentage of matching.