hypothetical matlab's limit

조회 수: 3 (최근 30일)
Bio_Ing_Sapienza
Bio_Ing_Sapienza 2019년 2월 9일
댓글: John D'Errico 2019년 2월 9일
Hi everyone. I have to calculate a sumof a vector of doubles of 1x4884 components. When I use this function i get as ans=nan. I there a limit to the maximum number that matlab is able to calculate? If yes how can i change this cobstraint?
Thank you in advance
  댓글 수: 1
madhan ravi
madhan ravi 2019년 2월 9일
Without knowing what your data is , it's hard to answer.

댓글을 달려면 로그인하십시오.

답변 (1개)

Adam Danz
Adam Danz 2019년 2월 9일
편집: Adam Danz 2019년 2월 9일
I'm sure there is such a limit in Matlab but it's nowhere near a vector length of 4884.
The problem is that you have at least 1 NaN value in your data.
sum([1, NaN])
ans =
NaN
Use the 'omitnan' flag to ignore NaN values.
sum([1,NaN], 'omitnan')
ans =
1
To confirm that you have at least one NaN value in your data, if this next line returns True (1), you have NaN value(s).
any(isnan(yourData)) % to find where the NaNs are: find(isnan(yourData))
And here's a test to confirm that Matlab can handle vector lengths of 4884 (or even 4884000 for that matter).
sum(rand(1, 4884))
  댓글 수: 7
Adam Danz
Adam Danz 2019년 2월 9일
This Matlab summary covers most of your examples and also mentions rem(x,y) when x is inf or y is 0.
John D'Errico
John D'Errico 2019년 2월 9일
Yes. rem also makes sense.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by