フィルターのクリア

Weird!!!! Extremely simple question!! Can't assign values to first row of a sparse matrix, please help.

2 ビュー (過去 30 日間)
Hi, everyone
I got stuck by a very simple question. I simply can't believe that such a weird thing would happen here. I am using MATLAB 2016b.
I was trying to assign some values to a sparse matrix, but anyhow there is nothing in the first row of a sparse matrix, no matter what I give to the first row of the sparse matrix S.
Here is code:
S=sparse([],[],[],32,50,100);
s(1,21:30)=[1 1 1 1 7 5 1 1 1 1];
S(2,21:30)=[1 1 1 1 1 1 1 1 1 1];
S(3,21:30)=[1:10];
S(4,21:30)=[1 1 2 2 3 3 4 4 5 5];
The first row of matrix S is always empty. How come? What did I wrong?
Please help me out.
Thank you very much.

採用された回答

James Tursa
James Tursa 2016 年 12 月 1 日
編集済み: James Tursa 2016 年 12 月 1 日
Typo. You used a small case 's' in that first row assignment. Change that to an upper case 'S' and everything will be as expected. MATLAB is a case sensitive language.

その他の回答 (1 件)

Albert
Albert 2016 年 12 月 1 日
Thank you, James.
I know MATLAB is case sensitive, but I didn't realize that I used low case of the second 'S' in my code.
It's so good to stay in MATLAB community.
Thank you.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by