Access elements of sparse matrix without find()
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dieter Verbeke
il 20 Apr 2016
Risposto: James Tursa
il 20 Apr 2016
I am using a toolbox for algorithmic differentiation. The output is a sparse matrix like this:
(1,1) 0 (50,2) 0.17 (99,3) 0.456
How can I access these elements? With find() I lose the first element because one of the derivatives happens to be zero. The index of the first element is known so I assume there must be a way to do that.
0 Commenti
Risposta accettata
James Tursa
il 20 Apr 2016
If you store this matrix as sparse, then yes the (1,1) 0 element will not be physically stored and cannot be recovered with find. So you will need to store these elements differently. Maybe keep track of the derivative element indexing in another variable. I.e., you could have another sparse matrix that simply keeps track of where the derivatives are. e.g.,
(1,1) 1 (50,2) 1 (99,3) 1
Then this could be used to recover the index values for the derivatives, even the 0 ones.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Sparse Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!