MATLAB: Solve linear equation system with partially unknown coefficient matrix

least absolute deviationlinear equationmatrixunknown coefficients

Hello everybody,
I have a question concerning solving linear equation systems with matlab. Concidering I have an equation system: A*x=y.
x and y are column vectors, where all entrys are known. The data for x und y are measured values.
A is a square matrix, which is diagonal symmetric: . Also the matrix is linearly independent. I know, that some coefficients have to be 0.
Is there any way to solve this equation system in Matlab to get the missing coefficients of A?
In this example there are 8 unknown coefficients, but only 4 rows.
I have to say, that for x and y there are different measurements available, so I could expand these vectors to matrices:
I thought about a solution approach like least absolute deviation, but I don't know, how to consider in matlab the conditions:
  • zero elements
  • symmetric matrix
Is there any way to solve this problem? At the moment I'm not sure, if this is possible at all?
Thank you for your help!

Best Answer

Just using linear algebra, no extra tollbox is needed, of course n==1 is underdetermined problem
% Generate random matrix
n = 10;
L = rand(4);
A = L+L.';
A(3,1)=0;
A(4,2)=0;
A(2,4)=0;
A(1,3)=0;
A
% And X/Y data compatible with equation
X = rand(4,n)
Y = A*X;
clear A
% Engine
% Enforce symmetric
ij = nchoosek(1:4,2);
i = ij(:,1);
j = ij(:,2);
ku = sub2ind([4 4],i,j);
kl = sub2ind([4 4],j,i);
p = size(ij,1);
R = (1:p)';
M = kron(X.',eye(4));
sz = [p size(M,2)];
C = accumarray([R ku(:)],1,sz) + accumarray([R kl(:)],-1,sz);
% Enforce A(3,1) & ... A(4,2) == 0
K = sub2ind([4 4],[3, 4], ...
[1, 2]);
sz = [2 size(M,2)];
C0 = accumarray([(1:2)', K(:)],1, sz);
C = [C; C0];
p = size(C,1);
% Solve least squares with linear constraints
z = [M'*M, C';
C, zeros(p)] \ [M'*Y(:); zeros(p,1)];
A = reshape(z(1:16),4,4)