Maximum recursion limit of 500 reached error in matlab.
5 views (last 30 days)
Show older comments
Jay Hanuman
on 24 Oct 2016
Commented: Walter Roberson
on 26 Oct 2016
I have downloaded matlab file "Random vectors with fixed sum" I got following error
Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available
stack space can crash MATLAB and/or your computer.
Error in randfixedsum
I attach file Random vectors with fixed sum. how to solve this error.
0 Comments
Accepted Answer
Walter Roberson
on 24 Oct 2016
Remove the three lines you added,
m=6;n=6; a=0.3; b=0.5;s=2
[x,v] = randfixedsum(n,m,s,a,b)
set(0,'RecursionLimit',N)
Now in a different .m file, put in
m=6;n=6; a=0.3; b=0.5;s=2
[x,v] = randfixedsum(n,m,s,a,b)
12 Comments
More Answers (1)
Roger Stafford
on 25 Oct 2016
The code for ‘randfixedsum’ was written to have each column, not each row, of the resulting matrix x have the given sum s. If you want the rows to have the given sum, you will have to do a transpose on x.
As to the question of uniformity, there is a profound difference between a statistically uniform distribution and a strictly uniform distribution. The example of the figure which I included in the file exchange entry for randfixedsum at:
http://www.mathworks.com/matlabcentral/fileexchange/9700-random-vectors-with-fixed-sum
has the values m = 3, n = 16384, s = 1.25, a = 0, and b = 1. This means that in each of the 16384 columns of the output x the sum of the three elements (xyz coordinates) must equal 1.25, and all element values must lie between 0 and 1. In the figure this implies that all the red dots must lie within the planar hexagon shown there, and their distribution throughout the hexagon is uniform in a statistical sense, though not in a strict sense. Of course, in your example with only three samples (columns) the statistical uniformity cannot be very evident - a figure illustrating it would have only three dots at some random locations within the corresponding hexagon (or triangle.)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!