"Array exceed the predefined size"
1 回表示 (過去 30 日間)
古いコメントを表示
I'm running a simple program, and sometimes(yeah) i would be stuck in the following error:
What's more, it said that i wanted to create an array with size of 1x18446744073709551615 (17179869184.0GB)
OMG....
I'm just concating two arrays...
"player = [player,deck(1)]; deck = deck(2:end); "
From the environment section, i saw that the array was all fine, but when i click the botton to step, the program abort.
the player and deck are just two small arrays.
HELP.
3 件のコメント
回答 (1 件)
Walter Roberson
2020 年 5 月 2 日
I am not seeing that error.
I had to guess what your shufflecards function does.
I encounter
Index exceeds the number of array elements (14).
Error in jackall (line 39)
action = P(sub2ind([N_PLAYER_VALUE,N_DEALER_VALUE,N_ACE],state(1)-11,state(2),state(3)+1));
Which makes sense. You do not initialize P, and you store into
P(sub2ind([N_PLAYER_VALUE,N_DEALER_VALUE,N_ACE],state(1,1)-11,state(1,2),state(1,3)+1)) = action;
which builds it out to a certain size. Then you
state = stateFromHand(player,dealer_showed);
which changes state, and you try to do
action = P(sub2ind([N_PLAYER_VALUE,N_DEALER_VALUE,N_ACE],state(1)-11,state(2),state(3)+1));
but since the first element of the state increased due to the additional card being taken into account, the right hand side is trying to index into P at a location beyond what you initialized.
3 件のコメント
Walter Roberson
2020 年 5 月 2 日
I did guess that shufflecards was randperm(52)
>> type shufflecards.m
function shuffled = shufflecards()
shuffled = randperm(52);
end
I used your exact code other than guessing (correctly) for shufflecards, and I encountered the error message I indicated above.
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!