필터 지우기
필터 지우기

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

조회 수: 1 (최근 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 CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by