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 | |
---|
21 | function [d1,d2] = makesym(d) |
---|
22 | [m,k] = size(d); |
---|
23 | if m ~= k, |
---|
24 | error ('Matrix should be square.') |
---|
25 | end |
---|
26 | d1 = 0.5 * (d + d'); |
---|
27 | if nargout == 2, |
---|
28 | d2 = 0.5 * (d - d'); |
---|
29 | end |
---|
30 | return |
---|
Note: See
TracBrowser
for help on using the repository browser.