Are there any matrix balancing/scaling function in matab for complex rectagular matrices?
8 views (last 30 days)
Show older comments
I have a complex number matrix with 45 x 2 size. And it needs to be inverted. But the condition number is too large around 8000. So I need to perform matrix balancing to improve the condition number. Is there any function in matlab to perform this operation? I found functions like 'balance', but works only for square matrices.
0 Comments
Answers (3)
Bruno Luong
on 22 Feb 2023
Check out normalize
1 Comment
Bruno Luong
on 22 Feb 2023
Edited: Bruno Luong
on 22 Feb 2023
Here is how to use it
format long
% Generate some unbalance matrix
A=(rand([100,2])+1i*rand([100,2])).*[1e14 1];
y=rand(size(A,1),1);
[An,c,s]=normalize(A);
B = (An+c./s);
cond(A)
cond(B)
x = (B\y)./s(:) % should be more robust than the following
x = A\y
Steven Lord
on 22 Feb 2023
I have a complex number matrix with 45 x 2 size. And it needs to be inverted.
How exactly do you define inversion for a non-square matrix? The standard definition of matrix inverse requires that the matrix be square. There are definitions for generalized inverses; which one are you trying to use?
Or are you trying to solve a system of 45 equations in 2 unknowns? In that case, don't try to invert the matrix. Use the backslash operator instead. As an example with a smaller random coefficient matrix and a known solution of [2; 3]:
rng default % for reproducibility
A = randi([-10 10], 6, 2);
x = [2; 3];
b = A*x;
x2 = A\b % This should be the same as x
0 Comments
William Rose
on 22 Feb 2023
Edited: William Rose
on 22 Feb 2023
[edit : correct spelling]
You say you want to invert a 45x2 matrix. As you know, a non-square matrix does not have an inverse. But is does have a pseudoinverse. Let us compute G, using the data and the formula from your posting elsewhere:
load g1.mat
load t.mat
G = [g1 -g1.*t];
This particular G is complex, since the data you provided before was complex. Now compute the pseudo inverse:
pinvG=pinv(G);
Confirm that pinvG*G is approximately the identity matrix:
pinv(G)*G
Try it.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!