Sparse matrix into square by adding zeros

8 ビュー (過去 30 日間)
Axelina
Axelina 2024 年 4 月 8 日
回答済み: Rishi 2024 年 4 月 8 日
Hi!
I am working with a sparse matrix that is size 6893x6881 but I would like it to be square i.e. 6893x6893. Does anyone have a suggestion on how to add zeros so that my matrix is square?

回答 (1 件)

Rishi
Rishi 2024 年 4 月 8 日
Hi Axelina,
I understand from your query that you want to convert your 6893x6881 sparse matrix to a 6893x6893 square matrix.
Assuming that your matrix is name 'm', this can be done by the following line of code:
m(:,6893) = 0;
This populates the columns till 6893 with value 0.
Hope this helps!

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by