Symbolic computation ERROR?
1 回表示 (過去 30 日間)
古いコメントを表示
Yuechuan Chen
2019 年 12 月 11 日
コメント済み: Walter Roberson
2019 年 12 月 12 日
p=sym('5744092954902128823202697');
randi([2,p-2])
So I've defined p and tried to compute randi([2,p-2]), Matlab returns: 'Size and range inputs must be numeric.'.
I know it's something to do with the symbolic variable but I do not know why this is happening, nor the solution. Is there a way to do this without converting p to numeric because I don't want to lose precision
THANK YOU!
0 件のコメント
採用された回答
Walter Roberson
2019 年 12 月 11 日
編集済み: Walter Roberson
2019 年 12 月 11 日
Rsymproc = feval(symengine, 'random', p-3);
Rsym = @() feval(symengine, Rsymproc) + 1;
Now each call to Rsym() will return one random number in the range [2, p-2]
Note: the internal procedure generated for this does not accept array sizes, so to generate multiple values, call Rsym multiple times.
3 件のコメント
Walter Roberson
2019 年 12 月 12 日
You do not need to
feval(symengine, Rsym)
You can just
Rsym()
You are correct in your intepretation of how the functions work.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!