現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Can I calculate the inverse of a matrix using arrayfun?
1 回表示 (過去 30 日間)
古いコメントを表示
Dear All,
I have a sparse matrix A. I want to calculate its inverse. I used the following way to calculate invA.
invA = A \ speye(size(A));
My matrix size is 3000 by 3000. I found it took me 1.3 seconds to get invA. It is longer than I expected.
I am wondering if I could use arrayfun to calculate invA. The idea is to calculate each column in invA by invA(:,i) = A \ ei, where ei is a zero column vector except its ith element is 1.0.
I tried the following code to implement the above idea:
invA = arrayfun(@(x) A\x ,speye(size(A,1)));
But I got error message.
Thanks a lot.
Benson
1 件のコメント
採用された回答
Walter Roberson
2021 年 6 月 25 日
編集済み: Walter Roberson
2021 年 6 月 25 日
invA = cell2mat(arrayfun(@(C) A\sparse(C,1,1,size(A,1),1), 1:size(A,2), 'uniform', 0))
I would be surprised if it is faster.
8 件のコメント
Walter Roberson
2021 年 6 月 25 日
A = sprand(20,20, .01)
A =
(5,2) 0.2696
(4,4) 0.9628
(9,5) 0.0991
(18,17) 0.8745
tic
invA = cell2mat(arrayfun(@(C) A\sparse(C,1,1,size(A,1),1), 1:size(A,2), 'uniform', 0))
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
invA =
(1,1) NaN
(3,1) NaN
(6,1) NaN
(7,1) NaN
(8,1) NaN
(9,1) NaN
(10,1) NaN
(11,1) NaN
(12,1) NaN
(13,1) NaN
(14,1) NaN
(15,1) NaN
(16,1) NaN
(18,1) NaN
(19,1) NaN
(20,1) Inf
(1,2) NaN
(3,2) NaN
(6,2) NaN
(7,2) NaN
(8,2) NaN
(9,2) NaN
(10,2) NaN
(11,2) NaN
(12,2) NaN
(13,2) NaN
(14,2) NaN
(15,2) NaN
(16,2) NaN
(18,2) NaN
(19,2) Inf
(20,2) NaN
(1,3) NaN
(3,3) NaN
(6,3) NaN
(7,3) NaN
(8,3) NaN
(9,3) NaN
(10,3) NaN
(11,3) NaN
(12,3) NaN
(13,3) NaN
(14,3) NaN
(15,3) NaN
(16,3) NaN
(18,3) Inf
(19,3) NaN
(20,3) NaN
(1,4) NaN
(3,4) NaN
(4,4) 1.0387
(6,4) NaN
(7,4) NaN
(8,4) NaN
(9,4) NaN
(10,4) NaN
(11,4) NaN
(12,4) NaN
(13,4) NaN
(14,4) NaN
(15,4) NaN
(16,4) NaN
(18,4) NaN
(19,4) NaN
(20,4) NaN
(1,5) NaN
(2,5) 3.7094
(3,5) NaN
(6,5) NaN
(7,5) NaN
(8,5) NaN
(9,5) NaN
(10,5) NaN
(11,5) NaN
(12,5) NaN
(13,5) NaN
(14,5) NaN
(15,5) NaN
(16,5) NaN
(18,5) NaN
(19,5) NaN
(20,5) NaN
(1,6) NaN
(3,6) NaN
(6,6) NaN
(7,6) NaN
(8,6) NaN
(9,6) NaN
(10,6) NaN
(11,6) NaN
(12,6) NaN
(13,6) NaN
(14,6) NaN
(15,6) NaN
(16,6) Inf
(18,6) NaN
(19,6) NaN
(20,6) NaN
(1,7) NaN
(3,7) NaN
(6,7) NaN
(7,7) NaN
(8,7) NaN
(9,7) NaN
(10,7) NaN
(11,7) NaN
(12,7) NaN
(13,7) NaN
(14,7) NaN
(15,7) Inf
(16,7) NaN
(18,7) NaN
(19,7) NaN
(20,7) NaN
(1,8) NaN
(3,8) NaN
(6,8) NaN
(7,8) NaN
(8,8) NaN
(9,8) NaN
(10,8) NaN
(11,8) NaN
(12,8) NaN
(13,8) NaN
(14,8) Inf
(15,8) NaN
(16,8) NaN
(18,8) NaN
(19,8) NaN
(20,8) NaN
(1,9) NaN
(3,9) NaN
(5,9) 10.0885
(6,9) NaN
(7,9) NaN
(8,9) NaN
(9,9) NaN
(10,9) NaN
(11,9) NaN
(12,9) NaN
(13,9) NaN
(14,9) NaN
(15,9) NaN
(16,9) NaN
(18,9) NaN
(19,9) NaN
(20,9) NaN
(1,10) NaN
(3,10) NaN
(6,10) NaN
(7,10) NaN
(8,10) NaN
(9,10) NaN
(10,10) NaN
(11,10) NaN
(12,10) NaN
(13,10) Inf
(14,10) NaN
(15,10) NaN
(16,10) NaN
(18,10) NaN
(19,10) NaN
(20,10) NaN
(1,11) NaN
(3,11) NaN
(6,11) NaN
(7,11) NaN
(8,11) NaN
(9,11) NaN
(10,11) NaN
(11,11) NaN
(12,11) Inf
(13,11) NaN
(14,11) NaN
(15,11) NaN
(16,11) NaN
(18,11) NaN
(19,11) NaN
(20,11) NaN
(1,12) NaN
(3,12) NaN
(6,12) NaN
(7,12) NaN
(8,12) NaN
(9,12) NaN
(10,12) NaN
(11,12) Inf
(12,12) NaN
(13,12) NaN
(14,12) NaN
(15,12) NaN
(16,12) NaN
(18,12) NaN
(19,12) NaN
(20,12) NaN
(1,13) NaN
(3,13) NaN
(6,13) NaN
(7,13) NaN
(8,13) NaN
(9,13) NaN
(10,13) Inf
(11,13) NaN
(12,13) NaN
(13,13) NaN
(14,13) NaN
(15,13) NaN
(16,13) NaN
(18,13) NaN
(19,13) NaN
(20,13) NaN
(1,14) NaN
(3,14) NaN
(6,14) NaN
(7,14) NaN
(8,14) NaN
(9,14) Inf
(10,14) NaN
(11,14) NaN
(12,14) NaN
(13,14) NaN
(14,14) NaN
(15,14) NaN
(16,14) NaN
(18,14) NaN
(19,14) NaN
(20,14) NaN
(1,15) NaN
(3,15) NaN
(6,15) NaN
(7,15) NaN
(8,15) Inf
(9,15) NaN
(10,15) NaN
(11,15) NaN
(12,15) NaN
(13,15) NaN
(14,15) NaN
(15,15) NaN
(16,15) NaN
(18,15) NaN
(19,15) NaN
(20,15) NaN
(1,16) NaN
(3,16) NaN
(6,16) NaN
(7,16) Inf
(8,16) NaN
(9,16) NaN
(10,16) NaN
(11,16) NaN
(12,16) NaN
(13,16) NaN
(14,16) NaN
(15,16) NaN
(16,16) NaN
(18,16) NaN
(19,16) NaN
(20,16) NaN
(1,17) NaN
(3,17) NaN
(6,17) Inf
(7,17) NaN
(8,17) NaN
(9,17) NaN
(10,17) NaN
(11,17) NaN
(12,17) NaN
(13,17) NaN
(14,17) NaN
(15,17) NaN
(16,17) NaN
(18,17) NaN
(19,17) NaN
(20,17) NaN
(1,18) NaN
(3,18) NaN
(6,18) NaN
(7,18) NaN
(8,18) NaN
(9,18) NaN
(10,18) NaN
(11,18) NaN
(12,18) NaN
(13,18) NaN
(14,18) NaN
(15,18) NaN
(16,18) NaN
(17,18) 1.1435
(18,18) NaN
(19,18) NaN
(20,18) NaN
(1,19) NaN
(3,19) Inf
(6,19) NaN
(7,19) NaN
(8,19) NaN
(9,19) NaN
(10,19) NaN
(11,19) NaN
(12,19) NaN
(13,19) NaN
(14,19) NaN
(15,19) NaN
(16,19) NaN
(18,19) NaN
(19,19) NaN
(20,19) NaN
(1,20) Inf
(3,20) NaN
(6,20) NaN
(7,20) NaN
(8,20) NaN
(9,20) NaN
(10,20) NaN
(11,20) NaN
(12,20) NaN
(13,20) NaN
(14,20) NaN
(15,20) NaN
(16,20) NaN
(18,20) NaN
(19,20) NaN
(20,20) NaN
toc
Elapsed time is 0.115353 seconds.
tic
invA = A\speye(size(A))
Warning: Matrix is singular to working precision.
invA =
(1,1) NaN
(3,1) NaN
(6,1) NaN
(7,1) NaN
(8,1) NaN
(9,1) NaN
(10,1) NaN
(11,1) NaN
(12,1) NaN
(13,1) NaN
(14,1) NaN
(15,1) NaN
(16,1) NaN
(18,1) NaN
(19,1) NaN
(20,1) Inf
(1,2) NaN
(3,2) NaN
(6,2) NaN
(7,2) NaN
(8,2) NaN
(9,2) NaN
(10,2) NaN
(11,2) NaN
(12,2) NaN
(13,2) NaN
(14,2) NaN
(15,2) NaN
(16,2) NaN
(18,2) NaN
(19,2) Inf
(20,2) NaN
(1,3) NaN
(3,3) NaN
(6,3) NaN
(7,3) NaN
(8,3) NaN
(9,3) NaN
(10,3) NaN
(11,3) NaN
(12,3) NaN
(13,3) NaN
(14,3) NaN
(15,3) NaN
(16,3) NaN
(18,3) Inf
(19,3) NaN
(20,3) NaN
(1,4) NaN
(3,4) NaN
(4,4) 1.0387
(6,4) NaN
(7,4) NaN
(8,4) NaN
(9,4) NaN
(10,4) NaN
(11,4) NaN
(12,4) NaN
(13,4) NaN
(14,4) NaN
(15,4) NaN
(16,4) NaN
(18,4) NaN
(19,4) NaN
(20,4) NaN
(1,5) NaN
(2,5) 3.7094
(3,5) NaN
(6,5) NaN
(7,5) NaN
(8,5) NaN
(9,5) NaN
(10,5) NaN
(11,5) NaN
(12,5) NaN
(13,5) NaN
(14,5) NaN
(15,5) NaN
(16,5) NaN
(18,5) NaN
(19,5) NaN
(20,5) NaN
(1,6) NaN
(3,6) NaN
(6,6) NaN
(7,6) NaN
(8,6) NaN
(9,6) NaN
(10,6) NaN
(11,6) NaN
(12,6) NaN
(13,6) NaN
(14,6) NaN
(15,6) NaN
(16,6) Inf
(18,6) NaN
(19,6) NaN
(20,6) NaN
(1,7) NaN
(3,7) NaN
(6,7) NaN
(7,7) NaN
(8,7) NaN
(9,7) NaN
(10,7) NaN
(11,7) NaN
(12,7) NaN
(13,7) NaN
(14,7) NaN
(15,7) Inf
(16,7) NaN
(18,7) NaN
(19,7) NaN
(20,7) NaN
(1,8) NaN
(3,8) NaN
(6,8) NaN
(7,8) NaN
(8,8) NaN
(9,8) NaN
(10,8) NaN
(11,8) NaN
(12,8) NaN
(13,8) NaN
(14,8) Inf
(15,8) NaN
(16,8) NaN
(18,8) NaN
(19,8) NaN
(20,8) NaN
(1,9) NaN
(3,9) NaN
(5,9) 10.0885
(6,9) NaN
(7,9) NaN
(8,9) NaN
(9,9) NaN
(10,9) NaN
(11,9) NaN
(12,9) NaN
(13,9) NaN
(14,9) NaN
(15,9) NaN
(16,9) NaN
(18,9) NaN
(19,9) NaN
(20,9) NaN
(1,10) NaN
(3,10) NaN
(6,10) NaN
(7,10) NaN
(8,10) NaN
(9,10) NaN
(10,10) NaN
(11,10) NaN
(12,10) NaN
(13,10) Inf
(14,10) NaN
(15,10) NaN
(16,10) NaN
(18,10) NaN
(19,10) NaN
(20,10) NaN
(1,11) NaN
(3,11) NaN
(6,11) NaN
(7,11) NaN
(8,11) NaN
(9,11) NaN
(10,11) NaN
(11,11) NaN
(12,11) Inf
(13,11) NaN
(14,11) NaN
(15,11) NaN
(16,11) NaN
(18,11) NaN
(19,11) NaN
(20,11) NaN
(1,12) NaN
(3,12) NaN
(6,12) NaN
(7,12) NaN
(8,12) NaN
(9,12) NaN
(10,12) NaN
(11,12) Inf
(12,12) NaN
(13,12) NaN
(14,12) NaN
(15,12) NaN
(16,12) NaN
(18,12) NaN
(19,12) NaN
(20,12) NaN
(1,13) NaN
(3,13) NaN
(6,13) NaN
(7,13) NaN
(8,13) NaN
(9,13) NaN
(10,13) Inf
(11,13) NaN
(12,13) NaN
(13,13) NaN
(14,13) NaN
(15,13) NaN
(16,13) NaN
(18,13) NaN
(19,13) NaN
(20,13) NaN
(1,14) NaN
(3,14) NaN
(6,14) NaN
(7,14) NaN
(8,14) NaN
(9,14) Inf
(10,14) NaN
(11,14) NaN
(12,14) NaN
(13,14) NaN
(14,14) NaN
(15,14) NaN
(16,14) NaN
(18,14) NaN
(19,14) NaN
(20,14) NaN
(1,15) NaN
(3,15) NaN
(6,15) NaN
(7,15) NaN
(8,15) Inf
(9,15) NaN
(10,15) NaN
(11,15) NaN
(12,15) NaN
(13,15) NaN
(14,15) NaN
(15,15) NaN
(16,15) NaN
(18,15) NaN
(19,15) NaN
(20,15) NaN
(1,16) NaN
(3,16) NaN
(6,16) NaN
(7,16) Inf
(8,16) NaN
(9,16) NaN
(10,16) NaN
(11,16) NaN
(12,16) NaN
(13,16) NaN
(14,16) NaN
(15,16) NaN
(16,16) NaN
(18,16) NaN
(19,16) NaN
(20,16) NaN
(1,17) NaN
(3,17) NaN
(6,17) Inf
(7,17) NaN
(8,17) NaN
(9,17) NaN
(10,17) NaN
(11,17) NaN
(12,17) NaN
(13,17) NaN
(14,17) NaN
(15,17) NaN
(16,17) NaN
(18,17) NaN
(19,17) NaN
(20,17) NaN
(1,18) NaN
(3,18) NaN
(6,18) NaN
(7,18) NaN
(8,18) NaN
(9,18) NaN
(10,18) NaN
(11,18) NaN
(12,18) NaN
(13,18) NaN
(14,18) NaN
(15,18) NaN
(16,18) NaN
(17,18) 1.1435
(18,18) NaN
(19,18) NaN
(20,18) NaN
(1,19) NaN
(3,19) Inf
(6,19) NaN
(7,19) NaN
(8,19) NaN
(9,19) NaN
(10,19) NaN
(11,19) NaN
(12,19) NaN
(13,19) NaN
(14,19) NaN
(15,19) NaN
(16,19) NaN
(18,19) NaN
(19,19) NaN
(20,19) NaN
(1,20) Inf
(3,20) NaN
(6,20) NaN
(7,20) NaN
(8,20) NaN
(9,20) NaN
(10,20) NaN
(11,20) NaN
(12,20) NaN
(13,20) NaN
(14,20) NaN
(15,20) NaN
(16,20) NaN
(18,20) NaN
(19,20) NaN
(20,20) NaN
toc
Elapsed time is 0.018112 seconds.
Benson Gou
2021 年 6 月 25 日
Hi, Walter,
Thanks for your help.
I compared your code and my original code. Your code took 3.7 sceonds while mine took 1.27 seconds.
I am wondering if there exists a faster code than my original code.
Thanks a lot, anyway.
Benso
Walter Roberson
2021 年 6 月 25 日
Well, you could try matrix decomposition, https://www.mathworks.com/help/matlab/ref/decomposition.html
Benson Gou
2021 年 6 月 25 日
Hi, Walter,
Yes, decomposition is a good way to solve linear systems. But I need the inverse of the matrix for other calculations, not just solve the linear system.
Thanks a lot.
Benson
Walter Roberson
2021 年 6 月 25 日
You decompose the matrix. Then you use the decomposition on the left side of \ with speye() on the right hand side.
Most of the time you should not be using the inverse in calculations, and should instead be using the \ operator . inv(A)*b + inv(A)*c --> dA = decompose(A), dA\b +dA\c
Benson Gou
2021 年 6 月 29 日
Hi, Walter,
I do not have the Image Processing Toolbox. So I cannot run decompose(A).
But the goal that I want to obtain the inverse of A is becaus I need to find out the nonzero elements in invA. So I do not know if decompose(A) is able to be useful for my case.
Thanks a lot.
Benson
その他の回答 (1 件)
Sulaymon Eshkabilov
2021 年 6 月 25 日
編集済み: Sulaymon Eshkabilov
2021 年 6 月 25 日
In fact, you can employ arrayfun for the matric inverse calc, e.g.:
tic;
iA =arrayfun(@inv,A);
toc;
Note that arrayfun is not the best option and does not take the sparse matrix.
Just direct inv() is the fastest so far.
In fact, for solving linear systems, to compute the inverse is not advised.
4 件のコメント
Walter Roberson
2021 年 6 月 25 日
A = sprand(20,20, .01)
A =
(16,5) 0.5706
(10,12) 0.5464
(12,16) 0.7549
(4,17) 0.6957
iA = arrayfun(@inv, full(A))
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
iA = 20×20
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf 1.4373 Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf 1.8301 Inf Inf Inf Inf Inf Inf Inf Inf
iA2 = 1./A
iA2 = 20×20
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf 1.4373 Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf
Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf 1.8301 Inf Inf Inf Inf Inf Inf Inf Inf
Walter Roberson
2021 年 6 月 25 日
By the way, you cannot apply arrayfun() directly to a sparse matrix.
Benson Gou
2021 年 6 月 29 日
Hi, Walter,
Yes, the decomposition is faster than \ operator. Thanks a lot.
Benson
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)