How to resolve problem in for loop?

조회 수: 2(최근 30일)
Ammy 2021년 12월 11일
댓글: Ammy 2021년 12월 11일
for i=1:a
Undefined function '_colonobj' for input arguments of type 'java.math.BigInteger'.
Any help in this regard is much appreciated. Thanks


John D'Errico
John D'Errico 2021년 12월 11일
편집: John D'Errico 2021년 12월 11일
Is "a" a number, in the form MATLAB will expect it? NO! a is a BigInteger number. You cannot use the colon operator on a.
a = 100
whos a
Name Size Bytes Class Attributes a 1x1 java.math.BigInteger
So you could have used a loop like this:
for i = 1:double(a)
As far as the actual loop goes, What do you think this
Operator '*' is not supported for operands of type 'java.math.BigInteger'.
does? NOTHING. Well, it does something. It throws an error. Because again, multiplcation is NOT supported in MATLAB between java.math.BigInteger objects. And even if it was supported, it would do nothing useful in MATLAB, just dumping the result into the bit bucket.
Anyway, if you want to multiply BigInteger numbers, the Java toolbox provides such a tool. Admittedly, it is a bit of a pain in the neck. This is why I put my own wrapper around those tools for use in MATLAB.
  댓글 수: 4
Ammy 2021년 12월 11일
@John D'Errico thank you very much for explanation I got your point, thank you very much.

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

Community Treasure Hunt

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

Start Hunting!

Translated by