How do I do random integers between (100*pi and 200*pi)?

1 回表示 (過去 30 日間)
Azairis
Azairis 2019 年 12 月 2 日
コメント済み: Azairis 2019 年 12 月 2 日
I keep getting the error that IMIN has to be smaller or equal to IMAX.
Fspeed = randi([100*pi 200*pi])
Also, for an object that is animated how do I allow the user to click the element they have to click -
%let user catch
[xClic, yClic] = ginput(3);
  1 件のコメント
Adam
Adam 2019 年 12 月 2 日
You should always give complete error messages with questions. The actual error you get when you do that is:
Error using randi
First input must be a positive scalar integer value IMAX, or two integer values [IMIN IMAX] with IMIN less than or equal to IMAX.
You just interpreted parts of the error message and ignored the bits that were actually relevant to your case - i.e. that the values must be integers.

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

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 2 日
編集済み: KALYAN ACHARJYA 2019 年 12 月 2 日
100*pi or 200*pi are not integers
>> 100*pi
ans =
314.1593
For randi case
randi([IMIN IMAX],1);
here the input must be a positive scalar integer value IMAX or IMAX
You can do this one:
Fspeed=randi([round(100*pi),round(200*pi)],1)
Please post a separate question for 2nd question.
  3 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 2 日
Agreed @Steven Thanks
Azairis
Azairis 2019 年 12 月 2 日
Thanks for the help!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by