For random walk in higher dimensions we can use a similar approach as mentioned in the code for 2 dimensional random walk. The code snippet below might be helpful to generate random walk in high dimensions:
nSteps = input('Enter the number of steps in a single run: ')
nRepeats = input('Enter the number of simulation runs to do: ');
nDims = input('Enter the number of Dimensions: ');
w_position = zeros(nSteps,nDims);
x = sign(randn([1,nDims]));
w_position(j+1,:) = w_position(j,:) + x;
Here w_position stores the position at the ith instant in the ith row.
Hope this helps!