Yeah, I did. I dont understand how to do it without a loop. I've tried s=full(sparse(1:3,1,k,5,3)). Cant add k to 2-nd and 3-rd column.
How do I create a sparse matrix of the following form?
1 view (last 30 days)
Show older comments
Hello.
Im trying to create a sparse matrix for some vector k, for example [1;2;3], of the following form:
k = [1;2;3];
1 0 0
2 1 0
M = 3 2 1
0 3 2
0 0 3
I can not undarstand how to use 'sparse' function to do it. Many thanks for any suggestions!
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Sparse Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!