how to create an array(1 by 5000) having random values in the range(9-11).

3 ビュー (過去 30 日間)
sanky kumar
sanky kumar 2013 年 9 月 10 日
i have to put the array value as input for sine function, but i guess there are certain limitations for that. it would be great if you could help P.S: new to matlab excuse my immaturity.

回答 (1 件)

Attila
Attila 2013 年 9 月 10 日
Hi,
Use the uniform distribution function rand(), that outputs values between 0..1 and multiply the values by 2 and add the base 9:
uni = rand(1,5000)*2 + 9
  2 件のコメント
sanky kumar
sanky kumar 2013 年 9 月 10 日
can i use this array as input for sine function? i guess we'll have some limitations please shed light on this issue
Attila
Attila 2013 年 9 月 10 日
編集済み: Attila 2013 年 9 月 10 日
There are no limitations. As sine is a periodic function, you can input almost any value. It will return a vector with an identical shape as the input.
results = sin(uni)
plot(1:5000, results, 1:5000, uni)
Is this what you needed?
Edit: MATLAB encourages working with matrices instead of loops. Usually there is a workaround to avoid loops and most of the basic functions can accept vector inputs.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by