help using sparse matrix

2 ビュー (過去 30 日間)
Kobi
Kobi 2014 年 2 月 12 日
コメント済み: Jos (10584) 2014 年 2 月 13 日
i have a big matrix 10e3x10e3 with small values 1e-10,1e-2,to save memory and speed i need the sparse function to not only ignore the zero elements but also those very small elements in the range (1e-10,1e-2) is it possible?

採用された回答

the cyclist
the cyclist 2014 年 2 月 12 日
編集済み: the cyclist 2014 年 2 月 12 日
You could preprocess your matrix with a step like
M(abs(M)<1.e-2) = 0;
and then make it sparse.

その他の回答 (1 件)

Kobi
Kobi 2014 年 2 月 13 日
i don't get it the resault is not as i expected:
>> a=[1,2,3;4,5e-12,0;9,8,7]
a =
1.0000 2.0000 3.0000
4.0000 0.0000 0
9.0000 8.0000 7.0000
>> aS=sparse(a)
aS =
(1,1) 1.0000
(2,1) 4.0000
(3,1) 9.0000
(1,2) 2.0000
(2,2) 0.0000
(3,2) 8.0000
(1,3) 3.0000
(3,3) 7.0000
>> a(abs(a)<1.e-2)
ans =
1.0e-11 *
0.5000
0
what is that answer? all the other constants from the matrix disappeared
  2 件のコメント
Jos (10584)
Jos (10584) 2014 年 2 月 13 日
The expression " a(abs(a)<1.e-2) " selects those elements from a that have an absolute value smaller than 1e-2. You do not want to select them, but set those elements to a zero
a(abs(a)<1e-2) = 0
Jos (10584)
Jos (10584) 2014 年 2 月 13 日
… and only after that convert those a to sparse!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSparse Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by