Remove element from sparse matrix

4 ビュー (過去 30 日間)
Dina Trajkovska
Dina Trajkovska 2016 年 3 月 3 日
コメント済み: Dina Trajkovska 2016 年 3 月 3 日
Hey, I have a question. I have a sparse matrix:
W = [6 7 9 5 10];
S = [1 1 2 3 4];
D = [2 3 4 4 1];
DG = sparse(S,D,W);
After some testing, it turns out I have to remove (1,3) 7 (I have only the digits from S - 1 and D - 3 though, and not from W - 7). How do I remove that row directly from the sparse matrix without using:
W(i) = [];
S(i) = [];
D(i) = [];
Please help! :D

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 3 月 3 日
DG(S(i), D(i)) = 0;
Depending on what you are doing it might also make sense to remove from S and D and W, but doing so would not in itself affect DG.
  1 件のコメント
Dina Trajkovska
Dina Trajkovska 2016 年 3 月 3 日
It works, thanks a lot! :D

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

カテゴリ

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