Complex number division of matrix over a vector

40 次查看(过去 30 天)
Hi, I am trying to divide a matrix that includes complex numbers with a vector that includes complex numbers. The cells in the resulting matrix are almost all equal to 0+0i. Why is that and how can I fix it to get the correct numbers?
Thanks

采纳的回答

John D'Errico
John D'Errico 2022-10-11
编辑:John D'Errico 2022-10-11
You SAID divide. You did not say you were solving a linear system of equations, as that is what backslash does. Regardless, I'll assume you really did intend to solve that linear system.
Looking at your arrays, we see:
load a_f
load r_end
load R_nd
whos R_nd r_end a_f
Name Size Bytes Class Attributes R_nd 15x90 21600 double complex a_f 90x1 1440 double complex r_end 1x15 240 double complex
So the computation:
a_f = -R_nd\r_end.';
Warning: Rank deficient, rank = 12, tol = 9.809482e-13.
solves the LINEAR system of equations for the vector x (you called it a_f), such that
(-R_nd)*x == r_end.'
But what does that mean? It needs to solve the problem for a vector of length 90.
You have only 15 equations. So backslash will compute only 15 non-zero unknowns. The other 75 of them will be EXACTLY zero. You don't have sufficient information content in those 15 equations to estimate 90 unknowns. All of those zeros are completely as expected.
nnz(a_f)
ans = 12
In fact, only 12 of them were non-zero, so it would appear that 3 of those equations were superfluous, and provided no additional information. This is consistent with the numerical rank of 12 as reported.
Anyway, why do I say the zeros are to be expected? Suppose I decided to solve a single equation,
x + y = 1
What is the solution? Linear algebra teaches us there are infinitely many choices we can make, infinitely many ways to solve that problem. The standard solution tells us to set some number of the unknowns to zero, since they are completely arbitrary. That is, we can arbitrarily choose to set x==0, and then compute y, or set y==0, and then compute x. Can we infer the value of BOTH x and y? Of course not. With limited informatino content, thus only 1 equation there, I cannot decide what both x and y must be.
There is one other common choice, and that is often called the minimum norm solution. (The minimum norm solution for the 2 variable problem I gave above would have x=y=1/2.) MATLAB returns that from the function lsqminnorm, thus
a_f = lsqminnorm(-R_nd,r_end.');
You could also have used other tools (some might suggest to use pinv, or lsqr, for example), but lsqminnorm may be what you want, and the name is quite descriptive. Really the choice is a bit arbitrary, since you simply do not have sufficient information to solve for all 90 unknowns.

更多回答(1 个)

David Hill
David Hill 2022-10-11
编辑:David Hill 2022-10-11
Obvisously the size of v must be consistent with the size of m. Attach your variables for additional help.
m=[randi(10,10)+1i*randi(10,10)];
v=[randi(10,1,10)+1i*randi(10,1,10)];
newMatrix=m./v
newMatrix =
1.1370 + 0.3014i 0.3538 - 0.8308i 0.7931 - 0.4828i 0.6931 + 0.9307i 1.3235 + 1.2059i 1.0610 + 0.5488i 0.6912 - 0.4853i 0.5122 - 0.6098i 2.6471 - 0.5882i 1.3571 - 0.0714i 1.1370 - 0.6986i 1.1385 - 0.1077i 0.6552 - 0.1379i 0.3663 + 0.6634i 0.4118 + 0.3529i 0.4634 + 0.1707i 0.5147 - 0.1912i 1.0854 - 0.7683i 2.3529 - 1.4118i 0.2143 - 0.0714i 1.2740 - 0.3973i 1.0154 - 0.1231i 0.6897 - 0.2241i 0.3267 + 0.2673i 0.4118 + 0.3529i 0.5610 + 1.0488i 0.7353 - 0.0588i 1.2195 - 0.9756i 1.9412 + 0.2353i 1.0000 + 0.0000i 1.0274 + 0.2603i 0.4000 - 0.2000i 0.8621 - 0.6552i 1.0000 + 0.0000i 1.1765 + 1.2941i 0.5732 + 0.1585i 0.5735 - 0.4559i 1.0732 - 0.6585i 2.1176 - 1.4706i 0.7143 - 0.4286i 0.7123 - 0.2329i 1.0000 - 1.0000i 0.3793 - 0.4483i 0.3267 + 0.2673i 1.5294 + 0.8824i 0.1707 + 0.5366i 1.0000 + 0.0000i 0.8902 - 0.0122i 1.1765 - 0.7059i 0.9286 + 0.5000i 1.2877 - 0.7671i 0.1846 - 0.4769i 0.5000 - 0.5000i 0.9505 + 0.5050i 1.2353 + 0.0588i 1.0488 + 0.4390i 0.5147 - 0.6912i 0.8049 - 0.2439i 2.6471 - 1.5882i 0.3571 + 0.2143i 0.5890 - 0.9041i 1.1231 + 0.0154i 0.3448 - 0.3621i 0.9406 + 0.4059i 1.1471 + 0.9118i 1.0732 + 0.6585i 0.4853 - 0.3088i 0.8537 - 0.6829i 2.5294 - 1.1176i 1.3571 + 0.0714i 1.0411 - 0.1096i 0.4769 - 0.8154i 0.9655 - 0.4138i 0.3564 + 0.5644i 1.3529 + 0.5882i 0.5366 + 0.8293i 0.8235 - 0.2059i 0.4268 - 0.8415i 2.7059 - 0.8235i 1.0000 + 0.4286i 0.8356 - 0.5616i 0.5077 - 1.0615i 0.8621 - 0.6552i 0.7921 + 0.9208i 0.8824 + 0.4706i 0.6707 + 0.0366i 0.9118 - 0.3529i 0.2561 - 0.3049i 2.6471 - 0.5882i 0.7857 - 0.0714i 0.5616 - 0.1644i 1.1538 - 0.2308i 0.7414 - 0.6034i 0.3168 + 0.1683i 0.6176 + 0.0294i 0.4268 + 0.8415i 0.7353 - 0.0588i 0.5610 - 0.0488i 1.7647 - 1.0588i 0.7143 + 0.4286i
  1 个评论
demos serghiou
demos serghiou 2022-10-11
Hi, thanks for the reply. Here are the files and operation I performed.
a_f = -R_nd\r_end.';

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by