2013-11-03 21 views
1

我想有這樣數學:有更新模塊的循環中有一個情節

TestModule[n_] := Module[{{dataList = {{0, 0}, {1, 2}}}}, 
For[i = 1, i <= n, i++, 
Pause[0.5]; 
Print[ ListLinePlot[dataList++]]; 
]; 
]; 

模塊,其中列表的值也會從迭代更新迭代,而不必模塊生產我的情節,我寧願只有一個情節,每次迭代後更新n次。

我已經看過Dynamics []和Monitor [],但還沒有找到解決方案。任何幫助表示讚賞。 :)

+0

好的,我已經明白了: ,i}, 打印[動態[ListViewLinePlot [dataList]]]; For [i = 1,i <= n,i ++, Pause [0.5]; dataList = dataList + 1; ]; ]; – user2949762

+0

爲什麼不使用'Manipulate'? – Ali

回答

1

這裏是Monitor一個簡單的應用:

TestModule[n_] := Module[{ 
    dataList = {{0, 0}, {1, 2}}, 
    plot = "starting..." 
    }, 
    Monitor[ 
    Do[ 
     Pause[0.5]; 
     plot = ListLinePlot[dataList++, PlotRange -> {0, n + 2}], 
     {i, 1, n} 
    ], 
    plot 
    ]; 
    plot 
]; 

你知道mathematica.stackexchange.com? TestModule [n_]:= Module [{dataList = {{0,0},{1,2}}}您可以從這裏獲得更多關於Mathematica特定問題的答案...