function y = abcdcheck(a,b,c,d)
% Check that dimensions of A,B,C,D are consistent.
% Give error message if not and return 1. Otherwise return 0.
Error = 0;
[ma,na] = size(a);
if (ma ~= na)
	Error = 'The A matrix must be square'
end
if (nargin > 1)
	[mb,nb] = size(b);
	if (ma ~= mb)
Error = 'The A and B matrices must have the same number of rows'
	end
	if (nargin > 2)
		[mc,nc] = size(c);
		if (nc ~= ma)
Error = 'The A and C matrices must have the same number of columns'
		end
		if (nargin > 3)
			[md,nd] = size(d);
			if (md ~= mc)
Error = 'The C and D matrices must have the same number of rows'
			end
			if (nd ~= nb)
Error = 'The B and D matrices must have the same number of columns'
			end
		end
	end
end
y = sign(Error(1));
