version 1.5, 2009/07/06 17:12:47
|
version 1.6, 2010/08/01 14:15:12
|
Line 1
|
Line 1
|
<problem> |
<problem> |
|
|
<script type="loncapa/perl"> |
<script type="loncapa/perl"> |
|
# |
|
# This example populates arrays with the x and y coordinates of the plot. |
|
# For continuous functions, another approach is to use curve plots. |
|
# |
$amplitude = &random(1,4,0.5); |
$amplitude = &random(1,4,0.5); |
$x_min = -5; |
$x_min = -5; |
$x_max = 5; |
$x_max = 5; |
for ($x=$x_min;$x<=$x_max;$x=$x+0.05) { |
for ($x=$x_min;$x<=$x_max;$x=$x+0.05) { |
push(@X,$x); |
push(@X,$x); |
push(@Y,$amplitude*sin($x)); |
push(@Y,$amplitude*sin($x)); |
|
# Safeguard: |
|
# The following line limits the size of the array to 1000 to avoid infinite loops |
|
if (($#X>1000) || ($#Y>1000)) { last; } |
} |
} |
</script> |
</script> |
|
|