How to plot a graph of sine function in Scilab?

Theory:

As we know the sine function is

y = \sin x

Where x is either in degree or in radian.

A program in Scilab for y = \sin x

Decoding:

  • In line no. 1, command clf(); is used to erase the previous plot in the graphic window.
  • Line no. 2 is for the loop over x from x = 0 to x=2\pi with step size 0.01.
  • Line no. 3 is for the sine function.
  • Line no. 4 is to plot the sine function. Here, the command leg is used for the legend which will appear in the graphics window.
To run your program, press the key “F5”, give a name to your file say “sine function” and then press the “Enter” key. You will see that a new graphic window will appear on the screen. Here you can see the graph of the sine function ranging from x = 0 to x = 2/pi .

Output

How to modify the graph?

To modify the axis, go to “Edit” and then “Axes properties”. A new window will appear on your screen called “Graphic Editor”. Here you can edit axes as well as compound properties. You can shift x-axes from the bottom to the middle. You can also change the size of the fount of axes. In the Compound Properties, you can change the color of your graph. You can also change the lines from solid to dot or double dots etc.

The graph after the above-mentioned modification is shown below. 

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
Right click not allowed
Index
Scroll to Top