


brede_mat_minus - Subtract a matrix from another
function C = brede_mat_minus(A, B)
Input: A 'Mat' structure
B 'Mat' structure
Property: Match [ {off} | columns ] Matching of columns
before subtraction
Output: C 'Mat' structure
This function will subtract one matrix from another (C = A-B)
For 'match' set to 'columns': If the columns contains strings
then the columns will be handled so the columns corresponding
to the same strings are subtracted. This will make the number
of columns at least as large as the largest matrix. The
matching takes place in the brede_mat_match function.
Any of the matrices might be a vector or a scalar.
Example:
% Subtraction with equal sized matrices
getfield(brede_mat_minus([1 2;3 4],[4 3;2 1]), 'matrix')
% Subtraction with scalar
M = brede_mat_minus(randn(100,100), 5)
figure, hist(M.matrix(:), sqrt(length(M.matrix(:))));
% Matching of columns
M1.columns = { 'First' 'Second' };
M1.matrix = [ 1 2 ];
M2.columns = { 'Second' 'First' };
M2.matrix = [ 2 1 ];
brede_mat_minus(M1,M2, 'match', 'columns') % This gives a zero matrix
% Substraction with a vector
M1 = brede_mat_mat2mat(rand(100,100));
M2 = brede_mat_mean(M1, 'type', 'rowmean');
M3 = brede_mat_minus(M1, M2)
M4 = brede_mat_mean(M3, 'type', 'rowmean');
max(M4.matrix)
See also BREDE, BREDE_MAT, BREDE_MAT_ADD, BREDE_MAT_DIVIDE,
BREDE_MAT_MAT2MAT, BREDE_MAT_MATCH,
BREDE_MAT_PRODUCT, BREDE_MAT_TRANSPOSE.
$Id: brede_mat_minus.m,v 1.3 2006/02/01 19:07:58 fnielsen Exp $