function out = stackmat(a, b)
% STACKMAT Stack two matrices vertically.
%	For example:
%	stackmat([1 2 3 4 5], [5 6; 7 8])
%
%	Roger Jang, 990224

if isempty(a), out = b; return; end
if isempty(b), out = a; return; end

[m1, n1] = size(a);
[m2, n2] = size(b);

out = zeros(m1+m2, max(n1, n2));
out(1:m1, 1:n1) = a;
out(m1+1:m1+m2, 1:n2) = b;
