Strange behaviour computing l1 norm of rows of a matrix

1 回表示 (過去 30 日間)
Christoph Neumann
Christoph Neumann 2020 年 7 月 22 日
コメント済み: James Tursa 2024 年 1 月 28 日
I have a (1102,8232)-matrix B (from Data that I don't have control over).
The query
B(1102,:)
yields
ans = All zero sparse: 1×8232
However, when I compute
beta = sum(abs(B),2);
or equivalently
beta = vecnorm(B,1,2)
I get
beta(1102)
ans = (1,1) 55
On the other hand, the command
norm(B(1102,:),1)
ans = 0
works as expected.
I'm really confused what's happening here. Any help is appreciated.

採用された回答

Bruno Luong
Bruno Luong 2020 年 8 月 13 日
編集済み: Bruno Luong 2020 年 8 月 13 日
Who build this sparse matrix B?
If it's build from external source it can be not-valid. I believe there is a tool on FileExchange to validate the sparse matrix, the name escapes me now.
EDIT: this command crahes my MATLAB
B = B+0
indicating this matrix has serious building flaw.
  6 件のコメント
Bruno Luong
Bruno Luong 2020 年 8 月 13 日
Yeah but be aware the fixed matrix might not be correct. You better try to fix at gurobi_read or python, whichever step that is responsible for the error.
James Tursa
James Tursa 2024 年 1 月 28 日
Note that spok has been removed from the FEX. You can use my replacement function sarek instead:

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by