This program plots a sine wave using the Show page.
Program
---
Store and Plot Sine Wave.
Generate the values for a sine wave, store in an array
and then plot them.
---
prog_vars =
d/point_no 0
d/current_angle 0.0
d/sine_value 0.0
d/plot_value 0
prog_vars.
prog_start =
pclear
print "Plot a Sone wave"
prog_start.
prog_loop =
plot_sine 100 0.0
exitnow
prog_loop.
plot_sine /no_of_points 0 /start_angle 0.0 =
-- Generate the sine wave data points and plot them.
print "Plot /no_of_points of Sine Wave"
/current_angle /start_angle
-- Loop through and plot the points
repeat /no_of_points ->
-- Calc the sine of the /current_angle
sin /current_angle -> /sine_value
-- Scale the Sine wave to fit.
mapf -1 1 -50 50 /sine_value -> /plot_value
plot 0 50 ^id=sine^w=500^h=200^xp=/point_no ^v1=/plot_value ^title=Sine Wave^
-- Next angle
inc /current_angle 0.5
inc /point_no
repeat.
plot_sine.
prog_stop =
print "Good bye"
prog_stop.