Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Matlab 3-d Walk problem
Date: Fri, 19 Nov 2010 01:50:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 11
Message-ID: <ic4l4d$1n9$1@fred.mathworks.com>
References: <ic4j4j$oqf$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1290131405 1769 172.30.248.38 (19 Nov 2010 01:50:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 19 Nov 2010 01:50:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1708920
Xref: news.mathworks.com comp.soft-sys.matlab:688219

Something like this perhaps, where the positions visited are recorded, rather than the steps.

position = zeros(3,N+1);
for k = 2:N+1
    step = 2*rand(3,1)-1;   % Create a random step in (x,y,z)
    step = step/norm(step);   % Normalise to unit length
    position(:,k) = position(:,k-1) + step;  % Add new step to last position
end

Hth
Darren