Random Number Generator with Decreasing Range

This is what I had:
for x=1:20
GraphMain=mexGraphNodeRemove(GraphMain,randi([0,21-x]))
end
I just want to remove a random node within an increasingly narrow range. I don't get an error message with this, but none of my nodes get deleted.

1 件のコメント

Guillaume
Guillaume 2015 年 6 月 30 日
The problem is most likely with mexGraphNodeRemove which looks like a mex file you've written. I don't see how we can help.
Note: I would assume that whatever GraphMain is, it has a property for the number of nodes, so rather than using a for loop, I would have used a while loop:
while GraphMain.NodeCount > 0 %or whatever way you have to get the number of nodes
GraphMain = mexGraphNodeRemove(GraphMain, randi([0 Graphmain.NodeCount]));
end

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeRandom Number Generation についてさらに検索

質問済み:

2015 年 6 月 30 日

コメント済み:

2015 年 6 月 30 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by