The domain for Matlab to choose from is always decreasing

Lets say I start off with a set number of N = 100. I have created a graph that goes along the x axis a random time, then randomley jumps or down 1 and then carries on.
In this graph, Matlab can essentially choose from any number within the interval [0,100] and can keep running on a loop over and over agai. What I want is that after it randomley jumps up or down 1, N = N - 1. So eventually you will get that N = 1 and the only option is for it to drop down 1 to 0. How do I do this?

Answers (1)

You could use a for-loop and randperm to do this:
result = zeros(100,1);
for ii = 1:100
result(ii) = randperm(ii,1);
end

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Asked:

on 29 Oct 2012

Community Treasure Hunt

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

Start Hunting!