Plotting for loop data

8 次查看(过去 30 天)
Estevan Munoz
Estevan Munoz 2018-11-21
回答: madhan ravi 2018-11-21
Hi, I'm relatively new to MATLAB and I'm a bit stuck on this problem. I am trying to create a random walk simulation by having a coin toss determine whether the "walker" will step left or right. I would like to plot every value of the position after each coin toss, but I only end up with the final position value. How can I plot every value? Here is what I have. Thanks in advance.
Screen Shot 2018-11-17 at 3.19.33 PM.png

回答(1 个)

madhan ravi
madhan ravi 2018-11-21
Use iterator as an index so that overwriting is avoided. Plus upload your code intead of picture next time onwards.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by