How to take the sum of all the values in an array ?

2 visualizzazioni (ultimi 30 giorni)
I have a Data in java. math.BigInteger format.
Data =
java.math.BigInteger[]:
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
For any two values we can add like this
result = Data(1).add(Data(2))
But how can we add all the values in the large Data?
  2 Commenti
Torsten
Torsten il 12 Ott 2022
uint64 as a MATLAB data type is not sufficient for your purpose ?
Noor Fatima
Noor Fatima il 12 Ott 2022
@Torsten Thank you very much, my data is in java.math.BigInteger, and as I think unit64 is not compatible with that.

Accedi per commentare.

Risposta accettata

David Hill
David Hill il 12 Ott 2022
import java.math.*
s=BigInteger('0');
for k=1:length(Data)
s=s.add(Data(k));
end
  2 Commenti
Noor Fatima
Noor Fatima il 12 Ott 2022
@David Hill I have also asked the question with the same format.
Please have a look on the following
https://www.mathworks.com/matlabcentral/answers/1823533-how-to-sort-rows?s_tid=srchtitle

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by