www.pudn.com > calibr8.zip > mvop.m
function result = mvop(matrix, vector, op) %result = MVOP(matrix, vector, op) % %Apply a binary array operation on a matrix-vector pair % %Input: % MATRIX - first argument (matrix M x N) % VECTOR - second argument (vector M x 1 or 1 x N) % OP - binary array operation % %Output: % RESULT - result of the operation applied to MATRIX and expanded VECTOR % %Example: % matrix = reshape(1:12, 4, 3)' % mvop(matrix, [1 2 3 4], '-') % mvop(matrix, [1; 2; 3], './') % %Radim Halir, Charles University Prague, halir@ms.mff.cuni.cz %Created: 6.6.1997 %Last modified: 6.6.1997 [m, n] = size(matrix); if (size(vector, 1) == 1) result = vector(ones(1, m), :); else result = vector(:, ones(1, n)); end result = feval(op, matrix, result);