version 1.3, 2007/07/30 21:52:21
|
version 1.4.8.1, 2010/08/20 03:54:56
|
Line 1
|
Line 1
|
<problem> |
<problem> |
|
|
<script type="loncapa/perl"> |
<script type="loncapa/perl"> |
# Enter computations here |
# |
### $amplitude = &random(1,4,0.5); |
# This example populates arrays with the x and y coordinates of the plot. |
### $x_min = -5; |
# For continuous functions, another approach is to use curve plots. |
### $x_max = 5; |
# |
### for ($x=$x_min;$x<=$x_max;$x=$x+0.05) { |
$amplitude = &random(1,4,0.5); |
### push(@X,$x); |
$x_min = -5; |
### push(@Y,$amplitude*sin($x)); |
$x_max = 5; |
### } |
for ($x=$x_min;$x<=$x_max;$x=$x+0.05) { |
|
push(@X,$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> |
|
|
<gnuplot width="300" transparent="off" samples="100" grid="on" font="9" bgcolor="xffffff" height="300" align="left" fgcolor="x000000" border="on" plottype="Cartesian" > |
<gnuplot width="300" transparent="off" samples="100" grid="on" font="9" bgcolor="xffffff" height="300" align="left" fgcolor="x000000" border="on" plottype="Cartesian" > |
<axis xmin="0" ymin="0" xmax="10" ymax="10" color="x000000" /> |
<axis xmin="$x_min" ymin="-5" xmax="$x_max" ymax="5" color="x000000" /> |
<xlabel>Label X</xlabel> |
<xlabel>Label X</xlabel> |
<ylabel>Label Y</ylabel> |
<ylabel>Label Y</ylabel> |
<curve linestyle="linespoints" name="My Plot" pointtype="0" color="x000000"> |
<curve linestyle="linespoints" name="My Plot" pointtype="0" color="x000000"> |
<data>1,2,3,4,5,6,7,8,9</data> |
<data>@X</data> |
<data>1,2,3,4,5,6,7,8,9</data> |
<data>@Y</data> |
</curve> |
</curve> |
</gnuplot> |
</gnuplot> |
|
|
<startouttext />Enter Question Text Here.<endouttext /> |
<startouttext />What is the amplitude of this function?<endouttext /> |
|
|
<numericalresponse answer=""> |
<numericalresponse answer="$amplitude" format="2s"> |
<responseparam name="tol" type="tolerance" description="Numerical Tolerance" default="5%" /> |
<responseparam name="tol" type="tolerance" description="Numerical Tolerance" default="5%" /> |
<responseparam name="sig" type="int_range,0-16" description="Significant Figures" default="0,15" /> |
|
<textline /> |
<textline readonly="no" /> |
<hintgroup> |
|
<startouttext /><endouttext /> |
|
</hintgroup> |
|
</numericalresponse> |
</numericalresponse> |
</problem> |
</problem> |
|
|