How to make a cell array where each entry represents a random?

A random walk is represented by a vector beginning with 0 and where each subsequent entry in the vector is attained from the previous entry by adding a random cohice of either 1 or -1. For example a vector representing a random walk could look like [0, −1, 0, 1, 2, 3, 2, 3, 4, 5]. Make a cell array named “RWL” of 100 entries where each entry represents a random walk up to absolute value 5.

2 件のコメント

Adam Danz
Adam Danz 2018 年 7 月 3 日
This sounds like a homework question. What have you tried so far? If you're stuck, post your code and the problem you're having.
kangbiao chen
kangbiao chen 2018 年 7 月 4 日
Sorry, I have posted my code already. Thanks for helping.

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

回答 (1 件)

Image Analyst
Image Analyst 2018 年 7 月 3 日

0 投票

Hint:
RWL = cell(100, 1);
for k = 1 : 100
thisWalk = .......
RWL{k} = ...
end
Also check into the randi() and cumsum() functions.

1 件のコメント

Image Analyst
Image Analyst 2018 年 7 月 4 日
OK, sounds like from your comment you've already submitted it. You're welcome.
For what it's worth, attached are some of my random walk demos.

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

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2018 年 7 月 3 日

コメント済み:

2018 年 7 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by