フィルターのクリア

How do I store all values of a loop in a vector?

1 回表示 (過去 30 日間)
Matthew
Matthew 2024 年 4 月 12 日
コメント済み: Dyuman Joshi 2024 年 4 月 19 日
for i=1:100000;
x=randi(6)+randi(6);
end;
I am trying to find an average across all values of x and need to save them all as a vector and can't figure out how
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2024 年 4 月 19 日
An alternate method without loop -
x = randi(6,1,1e5) + randi(6,1,1e5);

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

採用された回答

Voss
Voss 2024 年 4 月 12 日
x = zeros(1,100000);
for i=1:100000
x(i)=randi(6)+randi(6);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by