8 views (last 30 days)

Dear All,

I am trying to solve the following linear equation Ax=b:

[a1 a2 ... an][x1 x2 ... xn]' = b. where b is a complex number, a_i is also complex, and x_i is 1 or 0. This equation is unsolvable because the number of variables is n while the equation is 1. But if we add another condition: x is the sparse solution (number of nonzero entries is known) , there exists a unique solution.

For example, [0.1+0.2i 0.2+0.3i 0.4+0.5i 0.6+7i 0.8+0.9i]*[x1 x2 x3 x4 x5 x6 x7 x8 x9]' = 0.5+0.7i. If we know there are 2 non-zeros in x, then we got a unique solution x1=x3=1, others are zero.

But would someone tell me how to solve this equation using Matlab code?

Thanks a lot.

Benson

Bruno Luong
on 3 Jul 2019

Edited: Bruno Luong
on 3 Jul 2019

If you have optimization toolbox

A=[0.1+0.2i 0.2+0.3i 0.4+0.5i 0.6+7i 0.8+0.9i]

b = 0.5+0.7i;

nz = 2;

AA = [real(A); imag(A)]*10;

bb = [real(b); imag(b)]*10;

AA(end+1,:) = 1;

bb(end+1) = nz;

n = size(AA,2);

fdummy = ones(n,1);

lb = zeros(n,1);

ub = ones(n,1);

x = intlinprog(fdummy,1:n,[],[],AA,bb,lb,ub)

Solution returned is:

x =

1

0

1

0

0

If there are more than 1 solution, they can be obtained by changing fdummy.

Bruno Luong
on 18 Jul 2019

I suggest you to try formuate with the case p=Inf, it's not difficult when you write down the equation.

Edit: p=1 more difficult than p=Inf, and not as I wrong stated previously

Bruno Luong
on 18 Jul 2019

Edited: Bruno Luong
on 18 Jul 2019

Code for p = Inf and noise_threshold = 0.01;

A = [0.103+0.201i 0.196+0.294i 0.401+0.499i 0.602+6.993i 0.803+0.892i]

b = 0.5+0.7i;

noise_threshold = 0.01;

AA = [+real(A);

+imag(A);

-real(A);

-imag(A)];

bb = [+real(b);

+imag(b);

-real(b);

-imag(b)] + noise_threshold;

n = size(AA,2);

fdummy = ones(n,1);

lb = zeros(n,1);

ub = ones(n,1);

x = intlinprog(fdummy,1:n,AA,bb,[],[],lb,ub)

if isempty(x)

fprintf('noise_threshold = %f too small', noise_threshold);

end

% Check the "fit" result

A*x

b

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/470095-how-to-solve-a-special-linear-equation-ax-b-a-is-a-row-vector#comment_721026

⋮## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/470095-how-to-solve-a-special-linear-equation-ax-b-a-is-a-row-vector#comment_721026

Sign in to comment.