When I ran the following loop:
for i = 1 : 5^15
%
end
i
Matlab(R2007b) terminated when i equals 2^31-1 (2147483647). That's way too early. Do anyone have an explanation?

 채택된 답변

the cyclist
the cyclist 2015년 4월 2일
편집: the cyclist 2015년 4월 2일

0 개 추천

That is of course a quite ancient version. In MATLAB 2015a, the loop continues all the way to 5^15.
2^31-1 is the maximum representable integer in a 32-bit version of MATLAB, which yours is. I don't know the specifics, but it is presumably related to that.
What class of variable is i? I actually would have expected it to be a double, and therefore you would not have this problem.

댓글 수: 1

YEN
YEN 2015년 4월 2일
The variable i is actually a "double" so it should not be limited to 2^31-1. So strange. Thanks anyway.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

YEN
2015년 4월 2일

편집:

2015년 4월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by