How to add two sparse matrices or ndSparse matrices in MATLAB?
    6 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
I am aware that sparse matrices are most effciently worked with when they are created at once from a set of indices and values.
However, due to the size of my data, I am unable to store all indices and values at once, and am forced to batch my execution, so that a sparse matrix is built from a set of indices and values once in a while (say every 100th input file).
This introduces the problem of how to add two sparse matrices, which are not guaranteed to have the same dimension, as I need to accumulate the values (add them) if indices are identical.
I am currently using the ndSparse class from File Exchange, but would also be interested in an answer for MATLAB's built-in sparse function.
The main problem lies in making sure both sparse matrices have the same dimension. Is there any smart/efficient way to do this? Using padarray is not an option.
3 Kommentare
  Ahmad Gad
 am 16 Nov. 2017
				
      Bearbeitet: Ahmad Gad
 am 16 Nov. 2017
  
			Hi Jakob,
I am having the same problem as you exactly described in paragraphs one and two. However, I don't know how efficient is to discretize your calculation for all indices. Could you tell me how you did this and was it efficient or not?
Thanks in advance.
Antworten (1)
  Johannes Korsawe
      
 am 14 Okt. 2016
        help sparse
fourth and fifth argument of sparse prescribe the dimensions. If you know them from the beginning of ayour code, you can define all matrices of the same size and add them regularly.
0 Kommentare
Siehe auch
Kategorien
				Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
			
	Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


