source: distools/makesym.m @ 50

Last change on this file since 50 was 10, checked in by bduin, 14 years ago
File size: 654 bytes
Line 
1%MAKESYM Make a matrix symmetric
2%
3%   [B,C] = MAKESYM(A)
4%
5% INPUT
6%   A   Dataset or matrix
7%
8% OUTPUT
9%   B   Symmetric dataset or matrix computed as (A+A')/2
10%   C   Asymmetric remaining part, dataset or matrix computed as (A-A')/2
11%
12% DESCRIPTION
13% B is a symmetric matrix obtained by averiging values of A.
14%
15
16% Copyright: Elzbieta Pekalska, ela.pekalska@googlemail.com
17% EWI Faculty, Delft University of Technology and
18% School of Computer Science, University of Manchester
19
20
21function [d1,d2] = makesym(d)
22[m,k] = size(d);
23if m ~= k,
24  error ('Matrix should be square.')
25end
26d1 = 0.5 * (d + d');
27if nargout == 2,
28  d2 = 0.5 * (d - d');
29end
30return
Note: See TracBrowser for help on using the repository browser.