Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Problem with the stdin function in a code about partitions.

조회 수: 1 (최근 30일)
lorenzo donadio
lorenzo donadio 2016년 11월 8일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi, im creating a function that calculates the number of partitions of an integer k, but with values like 20 or higher it gives me this error:
File "<stdin>", line 4
SyntaxError: more than 255 argumentsFile "<stdin>",
this is the code, any suggestions? Thanks:
syms x ex Gs
k=input('enter an integer to calculate its partitions : ')
for j=1:k
for i=1:k
if(i*j>k)
break
end
ex(i,j)=(x^j)^i;
endfor
Gs(j)=1+sum(ex(:,j));
endfor
E=expand(prod(Gs));
c = coeffs(E);
Partitions=double(c(k+1))
  댓글 수: 2
Guillaume
Guillaume 2016년 11월 8일
Your code does not call any function called stdin (which is not a function that comes with matlab in any case).
Moreover, your code is not even valid matlab. endfor does not exist. It's just plain end.
Also note that matlab is not C. The brackets around the for expression and the if test are not needed.
Finally, in your code, x is undefined.
lorenzo donadio
lorenzo donadio 2016년 11월 8일
I forgot the first line where i defined x, and I compiled using octave, I know my program doest not call stdin thats why i find it weird, but I will try to run it with matlab to see if the error goes away

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by