loop with uniform distribution

1 回表示 (過去 30 日間)
hasan s
hasan s 2021 年 2 月 3 日
コメント済み: hasan s 2021 年 2 月 11 日
Hi
Let u(i) is uniform distribution in (0,1), with size (1 column contain 10 number), and the values of u(i) is different in every loop.since the values of u(i) is random uniform distribution will take any values in (0,1).
I want
the RESULT of t3 must contain 15 column ,and every column contain 10 number, with the values of u(i) is different in every i=1:15
this is my try ,what I change to get the above RESULT.
thanks a lot for any help.
sz = [10 1];
a=1.778;
for i=1:15
u(i) = unifrnd(0,1,sz)
t1=1 - u(i);
t2=t1/a;
t3=exp(t2);
end
t3

採用された回答

weikang zhao
weikang zhao 2021 年 2 月 4 日
  1. for loop is unnecessary;
  2. Wrong way to index matrix u;
  3. t1 is unnecessary cause t1 have the same probability distributions with u;
you can get t3 by:
t3=exp(unifrnd(0,1/1.778,10,15));
  2 件のコメント
hasan s
hasan s 2021 年 2 月 4 日
編集済み: hasan s 2021 年 2 月 6 日
thanks a lot for your help.
if possible , I need it as loop ...by using for...end
thank you very much
hasan s
hasan s 2021 年 2 月 11 日
I want to save the values of t3 ,
I try use
save t3
but when I close matlab and open it again....and recall the values t3 in another program ...will need to run the first program again to find t3..and the values will change since it is random
how I save the values t3 for ever.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by