Difference between revisions of "Scilab/C2/Getting-Started/English-timed"
From Script | Spoken-Tutorial
Line 593: | Line 593: | ||
|11.51 | |11.51 | ||
− | |Select the file myrecord.txt and click on | + | |Select the file myrecord.txt and click on Open. |
|- | |- |
Revision as of 16:55, 10 December 2013
Visual Cue | Narration |
---|---|
00.03 | Welcome to the spoken tutorial on Getting Started with Scilab. |
00.07 | In this tutorial we are going to learn: |
00.10 | The use Scilab as a calculator. |
00.13 | How to Store values in a variable. |
00.16 | How to Perform various mathematical operations using these variables. |
00.22 | How to Create a file to store commands executed during the session in the current working directory. |
00.29 | How to define complex numbers. |
00.32 | How to Perform exponential, logarithmic and trigonometric operations on numbers. |
00.38 | The prerequisite for this tutorial are Scilab should be installed on your computer. |
00.45 | I am using Scilab 5.2.0 and Mac OS(X) for demonstration |
00.52 | Here is the Flow chart for the tutorial. |
00.55 | Click on the Scilab shortcut icon on your Desktop and Start Scilab. |
01.01 | This is the Scilab console window. Notice that the cursor is on the command prompt. |
01.07 | I suggest that you practice this tutorial in Scilab simultaneously while pausing the video at regular intervals of time. |
01.17 | Scilab can be used as a calculator. Let us see some of the basic operations that it can do. |
01.25 | Type 42 plus 4 multiplied by 4 minus 64 divided 4 and press enter. |
01.36 | The output is 42, as expected. |
01.40 | Note that the answer 42 is stored in the default variable "a n s". |
01.45 | We can also create named variables: Type, |
01.49 | a equals 12,b=21 , and c=33 and press enter. |
02.00 | This stores the values 12,21 and 33 in the variables a,b and c respectively. |
02.08 | I will clear the scilab console using the clc command here |
02.14 | Now we will perform some mathematical operations using these variables. |
02.20 | For example, |
02.21 | a+b+c gives the result 66 |
02.27 | also |
02.29 | a times into bracket (b+c) gives the result 648 |
02.42 | We can also assign the answer to another variable say 'd' by typing d = bracket (a+b)
close the bracket multiplied by c gives the answer |
02.58 | d = 1089. |
03.02 | We can check the values in the variables by typing the names of the variables separated by commas on the command line as |
03.09 | a,b,c,d and press enter |
03.16 | I will clear the console here using the clc command |
03.22 | To take the power, use the “raised to” symbol which is located on the number key 6 of your keyboard. |
03.29 | Press ' shift key' and number key 6 to used this symbol. |
03.34 | for example, 7 square can be found by 7 raised to 2 and press Enter. |
03.44 | For finding the square root of a number, say, 17, we use : sqrt(17). |
03.55 | This is same as 17 raised to the power of zero point five. |
04.06 | By convention, only the positive value comes as output. |
04.10 | More generally, to find 34 to the power of (2 by 5), type: |
04.15 | 34 raised to bracket (2 divide by 5) and press Enter. |
04.25 | Negative powers can also be used, |
04.28 | Clear the cansole using clc command |
04.34 | So far, we have seen how to do some simple calculations and how to create variables in Scilab. |
04.41 | Now let us start with the new command. |
04.44 | This will helps remember command which were previously issued along with the outputs. |
04.49 | First type the command pwd and press Enter |
04.55 | This is the current working directory (on my computer). |
04.59 | It might be different on your computer |
05.01 | The current working directory can be changed by clicking the changed current directory icon located on the toolbar of the scilab console window as you see. |
05.15 | Now issue the diary command by typing: |
05.20 | diary bracket, open inverted commas, ('myrecord.txt') close inverted commas, close the bracket and press enter |
05.41 | This command will create a file with the name "myrecord.txt" in the current working directory. |
05.48 | A transcript of the Scilab session from now onwards will be saved in this file. |
05.53 | Its usefulness will be demonstrated at a later stage in this tutorial |
06.00 | Please pause the tutorial now and attempt exercise number one given with the video. |
06.07 | Now, let us see how Scilab handles complex numbers. |
06.13 | The imaginary unit i is defined in Scilab as percent i: |
06.19 | For example (Five point two multiplied percent i gives 5.2i |
06.29 | also bracket ( 10 plus 5 into percent i whole multiply by 2 times percent i gives the result -10. + 20.i |
06.58 | Now clear the console here, |
07.04 | Let us see some other predefined numerical constants available in Scilab. |
07.09 | As with i, their names also start with the percent sign: |
07.13 | For example, percent pi |
07.18 | The value of pi is as expected. |
07.21 | Now, we will demonstrate the use of pi using a few built-in trigonometric functions as follows. |
07.28 | For the functions sin of percent pi by 2 the result is 1' |
07.37 | And for cos of percent pi by 2 the result is 6.123D-17.' |
07.50 | Please note that the angles are measured in radians and |
07.54 | Notice that the second answer is zero for all practical purposes. |
07.59 | %eps is related to number known as "machine epsilon", |
08.04 | It is the minimum digit resolution that Scilab can give. |
08.08 | Type % eps on your console to find its value on your computer. |
08.19 | On my computer it gives 2.220D-16 |
08.24 | This shows the floating point precision used by Scilab . |
08.28 | This number is a notation for 2.22 times 10^(-16). Clear the console here. |
08.41 | If one wants to write 0.000456, one can write it as 4.56d-4 or 4.56e-4 |
09.06 | While scilab variables and functions are case-sensitive, here we can use small d or capital D, or small e, or capital E. |
09.17 | The base of the natural logarithm is another important predefined numerical constant: |
09.23 | percent e gives the result as expected. |
09.31 | We can achieve the same result with the function "e x p". |
09.35 | 'For example: exp bracket (1) close the bracket and press Enter |
09.45 | You can see both the answers are same |
09.47 | Clear the console using the clc command here. |
09.55 | similarly, |
09.56 | %e square gives the following answer |
10.04 | which can also be achieved by typing exp of 2 . |
10.18 | The command log means the natural logarithm of a number, that is, to the base e. |
10.24 | Use log 10 for taking the logarithm with respect to base 10. |
10.29 | For example, log10(1e-23) and press enter this gives the expected answer -23. |
10.47 | We get complex numbers when taking logarithm of negative. For complex numbers you can check this for yourself type : log(-1) or log(%i) on your scilab console |
11.01 | Now recall that we invoked a recording of all the typed commands into the file myrecord.txt through the diary command, now, let's see how to close that file and view it. |
11.14 | For closing the file, type, |
11.16 | diary of zero |
11.21 | This command will close and save the file myrecord.txt. |
11.26 | Also recall that this file was created in current working directory, which in my case is desktop. |
11.34 | Let us open this file to do click on the a Open-a-file shortcut icon on your scilab console window toolbar. |
11.46 | I will change the file format to all file |
11.51 | Select the file myrecord.txt and click on Open. |
11.59 | Note that all transactions, both commands and the corresponding answers given by Scilab, have been saved into this file. |
12.10 | I will close this file,click yes. |
12.21 | We know that, while a program is being developed, one experiments a lot with the code before arriving at suitable code. |
12.29 | Diary command helps to keep track of all the transactions. |
12.35 | If you recall that, we have closed the file my record.txt using the command diary of zero. |
12.42 | Please , note that no transactions can be saved after executing this command. |
12.48 | If we need to save the session once again, we need to issue the diary command again. |
12.54 | If the file contains some useful information, then one should use the some other file name in the diary command. |
13.03 | Because, use of same file name will overwrite the existing file. |
13.09 | Pause the video here and solve the second exercise given with the video. |
13.15 | You may have noticed that the solution for the problem was not exactly zero. |
13.24 | For more information on how to deal with this, type “help clean”.' |
13.28 | In general, if you need help about a particular command, then the 'help' or help with an argument command can be used. |
13.37 | For example,type “help chdir” on the scilab console and press enter. |
13.53 | I will increase the size of the help browser. |
14.01 | Help chdir gives detained information on how to change the current working directory'. |
14..10 | Another option is to click on the help browser icon on the toolbar of the scilab console window as you see. |
14.20 | Let me close the help browser and coming back to the slides. |
14.31 | The up - down arrow keys can been used to see the previously executed commands. |
14.36 | While using the up - down arrows, you can stop at any command,and press the Enter to execute it. |
14.45 | You can edit the commands, if necessary. |
14.48 | In fact, if you are looking for a previous command you typed, which started with the letter 'e', then type e, and then use up arrow key.' |
14.59 | Use the tab key to auto-complete the commad. It gives us all the available options to choose. |
15.08 | In this tutorial we have learnt : |
15.10 | Use of Scilab as a calculator . |
15.12 | Store the result in the default variable ans. |
15.16 | Assign values to the variable using the equality sign. |
15.21 | Check values in variables by typing the name of the variable separated by commas on the console. |
15.29 | Check the current working directory using pwd command. |
15.34 | Use diary command to save all commands typed on the console into a file. |
15.40 | Define complex numbers, natural exponents and π using %i, %e and %pi respectively. |
15.49 | Use help command for detailed information about any command. |
15.54 | This brings us to the end of this spoken tutorial on Getting Started with Scilab. |
15.59 | There are many other functions in Scilab which will be covered in other spoken tutorials. |
16.06 | * This spoken tutorial has been created by the Free and Open Source Software in Science and Engineering Education(FOSSEE). |
16.14 | * More information on the FOSSEE project could be obtained from http://fossee.in or http://scilab.in website |
16.23 | Supported by the National Mission on Eduction through ICT, MHRD, Government of India. |
16.29 | More information on this please visit spoken hyphen tutorial dot o r g slash NMEICT hyphen intro |
16.43 | I hope you find this spoken tutorial useful for learning. |
16.47 | Thank you. |
16.48 | This is Anuradha Amrutkar from IIT Bombay signing off. |
Contributors and Content Editors
Gaurav, Jyotisolanki, Krupali, PoojaMoolya, Sandhya.np14, Sneha