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

2 ビュー (過去 30 日間)
Noor Fatima
Noor Fatima 2022 年 10 月 12 日
コメント済み: Noor Fatima 2022 年 10 月 12 日
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 件のコメント
Torsten
Torsten 2022 年 10 月 12 日
uint64 as a MATLAB data type is not sufficient for your purpose ?
Noor Fatima
Noor Fatima 2022 年 10 月 12 日
@Torsten Thank you very much, my data is in java.math.BigInteger, and as I think unit64 is not compatible with that.

サインインしてコメントする。

採用された回答

David Hill
David Hill 2022 年 10 月 12 日
import java.math.*
s=BigInteger('0');
for k=1:length(Data)
s=s.add(Data(k));
end
  2 件のコメント
Noor Fatima
Noor Fatima 2022 年 10 月 12 日
Hi David,
Thank you !
Noor Fatima
Noor Fatima 2022 年 10 月 12 日
@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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by