Your cramer function defines b as
The loop within that function tries to store the empty value of b in B(:,i) which is of size [1x1] but b is of size [0,0] because it's empty.
That's why the error message reads,
Unable to perform assignment because the indices on the left side
are not compatible with the size of the right side.