% Computes the ratio of different elements between two arrays.
% 
% 	function [err] = computeError(a,b);
%
%   a and b can be either two numeric arrays of the same size, or two structure
%   arrays with identical field names where each field is a numeric array.
%
%	a and b are interchangeable.

%	ABN
%	Feb 9 2011

function err = computeError(a,b)

    if isstruct(a)
        if ~isstruct(b)
            error('Input arguments must be two numeric arrays or two structure arrays.')
        end
        if ~isequal(fieldnames(a), fieldnames(b))
            error('The two structure arrays input must have identical field names.')
        end
        % Recursion:
        c = fieldnames(a);
        for i = 1:length(c);
            err.(c{i}) = computeError(a.(c{i}), b.(c{i}));
        end
        return;
    end
            
	if size(a) ~= size(b)
	    if isequal(size(a),size(b'))
	        b = b';
        else
            error('The input vectors do not match in size.')
        end
	end

	err=sum(a~=b)/numel(a);
	