# some basic SM commands # a. startup sm # - to enter sm device x11 # should open a graphics window quit # to exit sm help # get general help menu in help device # get help on a specific keyword or task apropo # find related topics - may not work ls # list of functions in sm # b. learn to make a basic plot # try help command for each command below to better understand its use # this section from altmann tutuorial: use input file square.dat # read data from a file, plot in x11 window, annotate erase device x11 data square.dat # this file should be in the current directory lines 0 0 read x 1 read y 2 window 1 1 1 1 limits 0 5 0 25 box 1 2 0 0 ptype 3 3 ltype 2 points x y connect x y xlabel x (cm) ylabel y (cm) relocate 1 1 ltype 0 draw 5 5 # only an example of how to draw lines on the plot # c. examples of using vectors and variables: (explicit or from file, or ...) define i 10 define i ($i +1) echo $i set x = {1,2,3} print{x} # read in data from file.dat like this data "./file.dat" read {u 1 v 2 w 3} # u from col 1 etc. # generate random numbers using random set x = random(100) define prom (sum(x)/dimen(x)) echo $prom # histogram of randomly generated numbers define numer 100 #set y = random($numer) #set x = 0,1,0.1 set y = random($numer) * 40 + 50 set x = 50,90,4 set hy = histogram(y:x) erase window 1 1 1 1 define xup ($numer/4) # limits 0 1.1 0 $xup limits 0 100 0 $xup box 1 2 0 0 histogram x hy # define a vector like this, access as rr o rr[1] rr[2] etc # also can use set vec=start,end,delta to generate a series set rr = random(10) print{rr} # will print values # define a scalar like this define tt 3.14 # read in data from file.dat like this data "./file.dat" read {u 1 v 2 w 3} # u from col 1 etc. # min and max of a vector vecminmax u min max echo $min echo $max # size of a vector? set a=0,100,10 define size dimen(a) echo $size define tsum (sum(a)) echo $tsum # operations with vectors, and loops # vector operations (add, subract, multiply, select range and sum) # addressing individual values in a vector set a=0,10,1 define i (0) define a0 (a[$i]) echo $a0 do i=0,9,1 { define a0 (a[$i]) echo $a0 } # assigning values define i (0) do j=0,10,1 { set a[$i] = ($i * $i) define i ($i+1) } print{a} # choosing indices set a=0,100,10 set aselect= ( a>=30 & a<=70) print{aselect} set afinal=a*aselect print{afinal} # back to a basic plot data "./file.dat" read {u 1 v 2 w 3} # u from col 1 etc. device x11 # o device postencap "filename.ps" erase limits xmin xmax ymin ymax # o limits x y if x,y are vectors to plot box # draw box around plot # actual plotting connect u v # join points points u v # plot points # example histogram (cut and paste repeatedly for variation) erase define size (200) window 1 1 1 1 define yup ($size/5) limits 0 1 0 $yup box 1 2 0 0 set y = random($size) set x = 0,1,0.05 set histoy = histogram(y:x) histogram x histoy # example of using macros # make a file named class.sm # in this file the first line is the macro name (for this example: exmacro) # the following lines are the commands of the macro. These should be indented by one space # an example of the contents of file class.sm is: # #exmacro # define i (0) # do j=0,10,1 { # set a[$i] = ($i * $i) # define i ($i+1) # } # print{a} # # # now enter supermongo, and run the following commands # macro read class.sm # exmacro # # # end of file