Generates sin or cos wave using plot functions:
The script generates an x vector; iterating through all the values from 0 to 2*π in steps of 2*π /40 gives sufficient points to get a fine graph. It then finds the sine of each x value, and plots these points by using red o's. The command holds on freezes this in the figure window so the later plot will be superimposed. After that, it finds the cosine of each x value and plots these points by using blue +'s. The legend function generates a legend; the first string is paired with the first plot, and the next string with the next plot. Running this script generates the plot seen in the figure as shown below: