(Answer) (Category) LON-CAPA User Help : (Category) Authoring : (Category) Authoring Problems :
Gnuplot Example 2
<problem>

<script type="loncapa/perl">
# Enter computations here
#
# We will plot the graph of y=a sin((x-b)/2pi) by generating points
#
# The points will be stored in two arrays, @X and @Y.
#
$a = &random(2,5,0.5);
$b = &random(0,4,1);

$x_min = -8;
$x_max =  8;
$x_delta = 0.1;
for ($x = $x_min;$x<=$x_max;$x+=$x_delta) {
    push (@X,$x);
    push (@Y,($a*sin(($x-$b)/2*$pi)) );
}
</script>

<gnuplot font="large" width="600" samples="100" grid="on" height="300" 
        alttag="Sine Curve Plot" border="on" fgcolor="x000000" 
        align="center" bgcolor="xffffff" transparent="off">
    <axis ymin="-5" ymax="5" xmin="$x_min" xmax="$x_max" color="x000000" />
    <curve linestyle="linespoints" pointtype="0" color="x000000" name="Sine Curve">
        <data>@X</data>
        <data>@Y</data>
    </curve>
</gnuplot>

<startouttext /><br />
What is the amplitude of the sine curve graphed above?
<endouttext />

<numericalresponse answer="$a">
    <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 />
</numericalresponse>

</problem>

hallmat3@msu.edu
[Append to This Answer]
Previous: (Answer) Gnuplot Example 1
Next: (Answer) Can I create a problem which presents a choice from completely different questions?
This document is: http://help.loncapa.org/cgi-bin/fom?file=206
[Search] [Appearance] [Show This Answer As Text]
This is a Faq-O-Matic 2.719.
This FAQ administered by the LON-CAPA team at MSU. Submit a help request ticket to contact us.