Problem using the matlab function randsample

12 ビュー (過去 30 日間)
Knut Andre Skaug
Knut Andre Skaug 2019 年 10 月 9 日
コメント済み: Knut Andre Skaug 2019 年 10 月 9 日
I ask randsample to return a random samples from a 1 x 78000 vector with second argument being 50
example:
randsample(vector,50)
It throws an error message reading:
Error using randi
Too many input arguments.
Error in randsample line 153
x(randi(n,1,k-sumx)) = 1; sample w/replacement
I've tried the matlab example too, and it returns the same error message.
Any suggestions?
  1 件のコメント
Adam
Adam 2019 年 10 月 9 日
Works fine for me with a 1 x 78000 vector of random values. Are you using your offline help or online help? And are you using Matlab R2019b? If not you should always refer to your offline help, even if you first do an online search to find a help page. I have no idea if randsample has changed in recent versions though since it has been in the software since before 2006.

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2019 年 10 月 9 日
編集済み: Stephen23 2019 年 10 月 9 日
MATLAB is trying to access the wrong randi function.
This might occur if you created your own randi function, or a third-party toolbox has a function with this name.
You can check this easily:
which randi -all
The solution is rename that function, or remove it from the MATLAB Search Path:
  1 件のコメント
Knut Andre Skaug
Knut Andre Skaug 2019 年 10 月 9 日
There was another randi in a third-party toolbox.
Now it works, thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by