MATLAB Answers

Randi worked in a program I ran 5 weeks ago, today it doesn't-what gives?

Dear all,
I had a perfectly-functioning program that used this line:
c = randi([1,n],mn,1)
where n and mn are integers. I've re-opened the program to do a monte carlo simulation, and all I get is an error message stating:
Error using randi
Too many input arguments.
Mind you, I haven't changed a coma in the program. I'm just running it again to re-acquaint myself with had I had done.
Any thoughts?

  댓글 수: 0

로그인 to comment.


답변 수: 1

John D'Errico 님의 답변 17 Oct 2019
John D'Errico 님이 편집함. 17 Oct 2019
 채택된 답변

Don't write an m-file that is named randi, at least, if you will ever want to use randi. Try this:
which randi -all
If there is a function named randi that you created, then you did exactly that.
In general, avoid naming functions with existing function names. Check BEFORE you create that file.

  댓글 수: 6

표시 이전 댓글 수: 3
Regardless of what you think you have done, if you get an error message that tells you there are too many inpout arguments for randi, then you have done somethign to randi. So you need to tell us what the result of the which command is. Telling us the complete error message will also help. Because that will let us track down what you did.
You don't need to have changed ANYTHING in that particular program. You only need to have CREATED and saved a file named randi.
" I don't have a script named randi, or a function with that name."
MATLAB disagrees with you:
It appears you're using this toolbox. Delete it or at least remove it from your path since it shadows built-in functions randi and rng and maybe more.
I would also recommend getting in touch with them to complain about that shadowing.

로그인 to comment.

Translated by