Difference between revisions of "Scilab/C2/Iteration/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 1: Line 1:
 
{| border=1
 
{| border=1
|| ''Time'''
+
|| '''Time'''
 
|| '''Narration'''
 
|| '''Narration'''
 
  
 
|-
 
|-
  
|00.01
+
|00:01
  
 
| | Welcome to the spoken tutorial on iterative calculations using Scilab.
 
| | Welcome to the spoken tutorial on iterative calculations using Scilab.
Line 12: Line 11:
 
|-
 
|-
  
| 00.07
+
| 00:07
  
 
| | I am using scilab version 5.2 in Mac operating system ,
 
| | I am using scilab version 5.2 in Mac operating system ,
Line 18: Line 17:
 
|-
 
|-
  
| 00.11
+
| 00:11
  
 
| | but these calculations should work in other versions and also in Scilab that runs in linux and windows.
 
| | but these calculations should work in other versions and also in Scilab that runs in linux and windows.
Line 24: Line 23:
 
|-
 
|-
  
| 00.17
+
| 00:17
  
 
| | I will use the code available in the file iteration.sce
 
| | I will use the code available in the file iteration.sce
Line 30: Line 29:
 
|-
 
|-
  
|00.22
+
|00:22
  
 
|| I have opened this file using Scilab editor, which I plan to use only as an editor.
 
|| I have opened this file using Scilab editor, which I plan to use only as an editor.
Line 36: Line 35:
 
|-
 
|-
  
| 00.29
+
| 00:29
  
 
|| Let us create a vector using the colon operator i is equal to 1 colon 5.
 
|| Let us create a vector using the colon operator i is equal to 1 colon 5.
Line 42: Line 41:
 
|-
 
|-
  
| 00.38
+
| 00:38
  
 
| |creates a vector from 1 to 5, in increments of 1.
 
| |creates a vector from 1 to 5, in increments of 1.
Line 48: Line 47:
 
|-
 
|-
  
|00.42
+
|00:42
  
 
| | In this command,  i is equal to 1 colon 2 colon 5,
 
| | In this command,  i is equal to 1 colon 2 colon 5,
Line 54: Line 53:
 
|-
 
|-
  
| 00.51
+
| 00:51
  
 
| | We see that the middle argument of 2 indicates the increment.
 
| | We see that the middle argument of 2 indicates the increment.
Line 60: Line 59:
 
|-
 
|-
  
| 00.56
+
| 00:56
  
 
| | 1 is the first argument where the vector starts. I cannot go beyond 5.
 
| | 1 is the first argument where the vector starts. I cannot go beyond 5.
Line 66: Line 65:
 
|-
 
|-
  
| 01.01
+
| 01:01
  
 
| |It can be equal to 5, however.
 
| |It can be equal to 5, however.
Line 72: Line 71:
 
|-
 
|-
  
| 01.04
+
| 01:04
  
 
| | Note that if the ending argument changes to 6 the result remains the same.
 
| | Note that if the ending argument changes to 6 the result remains the same.
Line 78: Line 77:
 
|-
 
|-
  
|01.09
+
|01:09
  
 
| | It is not difficult to explain this behaviour.
 
| | It is not difficult to explain this behaviour.
Line 84: Line 83:
 
|-
 
|-
  
|01.13
+
|01:13
  
 
|  Can you think for a moment why this happens?
 
|  Can you think for a moment why this happens?
Line 90: Line 89:
 
|-
 
|-
  
| 01.15
+
| 01:15
  
 
|We will now demonstrate the use of the for statement to perform iterative calculations.
 
|We will now demonstrate the use of the for statement to perform iterative calculations.
Line 96: Line 95:
 
|-
 
|-
  
| 01.22
+
| 01:22
  
 
|for i is equal to 1 colon 2 colon 7 disp i end of for loop.
 
|for i is equal to 1 colon 2 colon 7 disp i end of for loop.
Line 102: Line 101:
 
|-
 
|-
  
| 01.28
+
| 01:28
  
 
| |I will cut this paste in scilab console press enter.
 
| |I will cut this paste in scilab console press enter.
Line 108: Line 107:
 
|-
 
|-
  
| 01.34
+
| 01:34
  
 
| |This code prints out i, as we go through the loop.
 
| |This code prints out i, as we go through the loop.
Line 114: Line 113:
 
|-
 
|-
  
| 01.37
+
| 01:37
  
 
| |The display is due to the command disp - the passed argument is displayed.
 
| |The display is due to the command disp - the passed argument is displayed.
Line 120: Line 119:
 
|-
 
|-
  
| 01.42
+
| 01:42
  
 
| |Recall that the for loop is used for integer values.
 
| |Recall that the for loop is used for integer values.
Line 126: Line 125:
 
|-
 
|-
  
| 01.45
+
| 01:45
  
 
| | In this case, four integer values, namely, 1, 3, 5 and 7 are displayed.
 
| | In this case, four integer values, namely, 1, 3, 5 and 7 are displayed.
Line 132: Line 131:
 
|-
 
|-
  
| 01.50
+
| 01:50
  
 
| |The number of times the iterations take place is known as priori in for loops.
 
| |The number of times the iterations take place is known as priori in for loops.
Line 138: Line 137:
 
|-
 
|-
  
|01.56
+
|01:56
  
 
| | In the rest of this tutorial, we will stick to the default increment of 1.
 
| | In the rest of this tutorial, we will stick to the default increment of 1.
Line 144: Line 143:
 
|-
 
|-
  
| 02.01
+
| 02:01
  
 
| |Let us begin with the loop that displays i equal to 1 to 5.
 
| |Let us begin with the loop that displays i equal to 1 to 5.
Line 150: Line 149:
 
|-
 
|-
  
| 02.10
+
| 02:10
  
 
| | We will modify this code by introducing the break statement.
 
| | We will modify this code by introducing the break statement.
Line 156: Line 155:
 
|-
 
|-
  
|02.18
+
|02:18
  
 
| Note that i is displayed only up to 2.
 
| Note that i is displayed only up to 2.
Line 162: Line 161:
 
|-
 
|-
  
|02.22
+
|02:22
  
 
| | The iteration is not carried out till the last value of i, namely 5.
 
| | The iteration is not carried out till the last value of i, namely 5.
Line 168: Line 167:
 
|-
 
|-
  
|02.27
+
|02:27
  
 
| | When i is equal to 2, the if block is executed for the first time.
 
| | When i is equal to 2, the if block is executed for the first time.
Line 174: Line 173:
 
|-
 
|-
  
| 02.30
+
| 02:30
  
 
| | The break command, however, terminates the loop.
 
| | The break command, however, terminates the loop.
Line 180: Line 179:
 
|-
 
|-
  
| 02.34
+
| 02:34
  
 
|| If we want to get out of a loop when some intermediate condition is satisfied, we can use the break statement.
 
|| If we want to get out of a loop when some intermediate condition is satisfied, we can use the break statement.
Line 186: Line 185:
 
|-
 
|-
  
| 02.40
+
| 02:40
  
 
| | Note that "i is equal to 2" statement uses the "equal to" sign twice.
 
| | Note that "i is equal to 2" statement uses the "equal to" sign twice.
Line 192: Line 191:
 
|-
 
|-
  
| 02.45
+
| 02:45
  
 
| | This is the standard way to compare the equality in programming languages.
 
| | This is the standard way to compare the equality in programming languages.
Line 198: Line 197:
 
|-
 
|-
  
|02.50
+
|02:50
  
 
| | The result of this comparison statement is a boolean: true or false.
 
| | The result of this comparison statement is a boolean: true or false.
Line 204: Line 203:
 
|-
 
|-
  
| 02.56
+
| 02:56
  
 
| | We will introduce the continue statement here paste press enter
 
| | We will introduce the continue statement here paste press enter
Line 210: Line 209:
 
|-
 
|-
  
| 03.06
+
| 03:06
  
 
|| This results in i getting displayed only for 4 and 5.
 
|| This results in i getting displayed only for 4 and 5.
Line 216: Line 215:
 
|-
 
|-
  
| 03.10
+
| 03:10
  
 
| | For i less than or equal to 3, as given by the i less than or equal to 3 statement, nothing happens.
 
| | For i less than or equal to 3, as given by the i less than or equal to 3 statement, nothing happens.
Line 222: Line 221:
 
|-
 
|-
  
| 03.18
+
| 03:18
  
 
| | The continue statement makes the program skip the rest of the loop.
 
| | The continue statement makes the program skip the rest of the loop.
Line 228: Line 227:
 
|-
 
|-
  
| 03.22
+
| 03:22
  
 
| Unlike the break statement, however, it does not exit the loop.
 
| Unlike the break statement, however, it does not exit the loop.
Line 234: Line 233:
 
|-
 
|-
  
| 03.25
+
| 03:25
  
 
| | The parameter i is incremented and all the calculations of the loop are executed for the new i.
 
| | The parameter i is incremented and all the calculations of the loop are executed for the new i.
Line 240: Line 239:
 
|-
 
|-
  
| 03.32
+
| 03:32
  
 
| | We take a small break and show how to get help for operators of the type less than or equal to.
 
| | We take a small break and show how to get help for operators of the type less than or equal to.
Line 246: Line 245:
 
|-
 
|-
  
| 03.38
+
| 03:38
  
 
| |Let us type less than or equal to with help
 
| |Let us type less than or equal to with help
Line 252: Line 251:
 
|-
 
|-
  
| 03.46
+
| 03:46
  
 
|| This opens the scilab help browser.
 
|| This opens the scilab help browser.
Line 258: Line 257:
 
|-
 
|-
  
| 03.51
+
| 03:51
  
 
|| We see that the help is available under the option less.
 
|| We see that the help is available under the option less.
Line 264: Line 263:
 
|-
 
|-
  
| 03.56
+
| 03:56
  
 
| | So now after closing this we type help less
 
| | So now after closing this we type help less
Line 270: Line 269:
 
|-
 
|-
  
|04.06
+
|04:06
  
 
|| We see the required help instructions here. I will close this.
 
|| We see the required help instructions here. I will close this.
Line 276: Line 275:
 
|-
 
|-
  
|04.11
+
|04:11
  
 
| | The for statement in Scilab is more powerful than in programming languages.
 
| | The for statement in Scilab is more powerful than in programming languages.
Line 282: Line 281:
 
|-
 
|-
  
| 04.16
+
| 04:16
  
 
| | For example, let us perform a loop over a vector:
 
| | For example, let us perform a loop over a vector:
Line 288: Line 287:
 
|-
 
|-
  
| 04.24
+
| 04:24
  
 
| | This script displays all values of v.
 
| | This script displays all values of v.
Line 294: Line 293:
 
|-
 
|-
  
| 04.28
+
| 04:28
  
 
| | Until now we have been displaying only the variables.
 
| | Until now we have been displaying only the variables.
Line 300: Line 299:
 
|-
 
|-
  
| 04.32
+
| 04:32
  
 
| | We can indeed display the result of a calculation as well.
 
| | We can indeed display the result of a calculation as well.
Line 306: Line 305:
 
|-
 
|-
  
| 04.35
+
| 04:35
  
 
| | The following code displays the square of the numbers.
 
| | The following code displays the square of the numbers.
Line 312: Line 311:
 
|-
 
|-
  
|04.44
+
|04:44
  
 
| | We have spent quite a bit of time explaining the for loop.
 
| | We have spent quite a bit of time explaining the for loop.
Line 318: Line 317:
 
|-
 
|-
  
| 04.48
+
| 04:48
  
 
| | Let us now move on to the while loops.
 
| | Let us now move on to the while loops.
Line 324: Line 323:
 
|-
 
|-
  
| 04.50
+
| 04:50
  
 
| | The while statement allows us to perform a loop when a boolean expression is true
 
| | The while statement allows us to perform a loop when a boolean expression is true
Line 330: Line 329:
 
|-
 
|-
  
| 04.55
+
| 04:55
  
 
| | At the beginning of the loop, if the expression is true,
 
| | At the beginning of the loop, if the expression is true,
Line 336: Line 335:
 
|-
 
|-
  
| 04.58
+
| 04:58
  
 
| |the statements in the body of the while loop are executed.
 
| |the statements in the body of the while loop are executed.
Line 342: Line 341:
 
|-
 
|-
  
| 05.02
+
| 05:02
  
 
| | If the program is written well, the expression becomes false and the loop is ended.
 
| | If the program is written well, the expression becomes false and the loop is ended.
Line 348: Line 347:
 
|-
 
|-
  
| 05.08
+
| 05:08
  
 
|| Now let us see an example for the while loop:
 
|| Now let us see an example for the while loop:
Line 354: Line 353:
 
|-
 
|-
  
|05.15
+
|05:15
  
 
| | The values of i, from 1 to 6 are displayed.
 
| | The values of i, from 1 to 6 are displayed.
Line 360: Line 359:
 
|-
 
|-
  
|05.19
+
|05:19
  
 
|| Break and continue statements inside the while loop work exactly as they did in the for loop, as we demonstrate using break:
 
|| Break and continue statements inside the while loop work exactly as they did in the for loop, as we demonstrate using break:
Line 366: Line 365:
 
|-
 
|-
  
|05.33
+
|05:33
  
 
| | We can see that the moment i becomes equal to 3, the program exits the loop, thanks to the break statement.
 
| | We can see that the moment i becomes equal to 3, the program exits the loop, thanks to the break statement.
Line 372: Line 371:
 
|-
 
|-
  
| 05.39
+
| 05:39
  
 
|| You can also try the example for continue statement in while loop.
 
|| You can also try the example for continue statement in while loop.
Line 378: Line 377:
 
|-
 
|-
  
| 05.44
+
| 05:44
  
 
| | This brings us to the end of this spoken tutorial on iterative calculations using Scilab.
 
| | This brings us to the end of this spoken tutorial on iterative calculations using Scilab.
Line 384: Line 383:
 
|-
 
|-
  
| 05.50
+
| 05:50
  
 
|| Spoken Tutorials are part of the Talk to a Teacher project, supported by the National Mission on Education through ICT.
 
|| Spoken Tutorials are part of the Talk to a Teacher project, supported by the National Mission on Education through ICT.
  
 
|-
 
|-
| 05.57
+
| 05:57
 
| | More information on the same is available at the following link [http://spoken-tutorial.org/NMEICT-Intro].
 
| | More information on the same is available at the following link [http://spoken-tutorial.org/NMEICT-Intro].
  
 
|-
 
|-
| 06.00
+
| 06:00
 
| |Thanks for joining.Good bye.
 
| |Thanks for joining.Good bye.
  
 
|}
 
|}

Revision as of 17:00, 10 July 2014

Time Narration
00:01 Welcome to the spoken tutorial on iterative calculations using Scilab.
00:07 I am using scilab version 5.2 in Mac operating system ,
00:11 but these calculations should work in other versions and also in Scilab that runs in linux and windows.
00:17 I will use the code available in the file iteration.sce
00:22 I have opened this file using Scilab editor, which I plan to use only as an editor.
00:29 Let us create a vector using the colon operator i is equal to 1 colon 5.
00:38 creates a vector from 1 to 5, in increments of 1.
00:42 In this command, i is equal to 1 colon 2 colon 5,
00:51 We see that the middle argument of 2 indicates the increment.
00:56 1 is the first argument where the vector starts. I cannot go beyond 5.
01:01 It can be equal to 5, however.
01:04 Note that if the ending argument changes to 6 the result remains the same.
01:09 It is not difficult to explain this behaviour.
01:13 Can you think for a moment why this happens?
01:15 We will now demonstrate the use of the for statement to perform iterative calculations.
01:22 for i is equal to 1 colon 2 colon 7 disp i end of for loop.
01:28 I will cut this paste in scilab console press enter.
01:34 This code prints out i, as we go through the loop.
01:37 The display is due to the command disp - the passed argument is displayed.
01:42 Recall that the for loop is used for integer values.
01:45 In this case, four integer values, namely, 1, 3, 5 and 7 are displayed.
01:50 The number of times the iterations take place is known as priori in for loops.
01:56 In the rest of this tutorial, we will stick to the default increment of 1.
02:01 Let us begin with the loop that displays i equal to 1 to 5.
02:10 We will modify this code by introducing the break statement.
02:18 Note that i is displayed only up to 2.
02:22 The iteration is not carried out till the last value of i, namely 5.
02:27 When i is equal to 2, the if block is executed for the first time.
02:30 The break command, however, terminates the loop.
02:34 If we want to get out of a loop when some intermediate condition is satisfied, we can use the break statement.
02:40 Note that "i is equal to 2" statement uses the "equal to" sign twice.
02:45 This is the standard way to compare the equality in programming languages.
02:50 The result of this comparison statement is a boolean: true or false.
02:56 We will introduce the continue statement here paste press enter
03:06 This results in i getting displayed only for 4 and 5.
03:10 For i less than or equal to 3, as given by the i less than or equal to 3 statement, nothing happens.
03:18 The continue statement makes the program skip the rest of the loop.
03:22 Unlike the break statement, however, it does not exit the loop.
03:25 The parameter i is incremented and all the calculations of the loop are executed for the new i.
03:32 We take a small break and show how to get help for operators of the type less than or equal to.
03:38 Let us type less than or equal to with help
03:46 This opens the scilab help browser.
03:51 We see that the help is available under the option less.
03:56 So now after closing this we type help less
04:06 We see the required help instructions here. I will close this.
04:11 The for statement in Scilab is more powerful than in programming languages.
04:16 For example, let us perform a loop over a vector:
04:24 This script displays all values of v.
04:28 Until now we have been displaying only the variables.
04:32 We can indeed display the result of a calculation as well.
04:35 The following code displays the square of the numbers.
04:44 We have spent quite a bit of time explaining the for loop.
04:48 Let us now move on to the while loops.
04:50 The while statement allows us to perform a loop when a boolean expression is true
04:55 At the beginning of the loop, if the expression is true,
04:58 the statements in the body of the while loop are executed.
05:02 If the program is written well, the expression becomes false and the loop is ended.
05:08 Now let us see an example for the while loop:
05:15 The values of i, from 1 to 6 are displayed.
05:19 Break and continue statements inside the while loop work exactly as they did in the for loop, as we demonstrate using break:
05:33 We can see that the moment i becomes equal to 3, the program exits the loop, thanks to the break statement.
05:39 You can also try the example for continue statement in while loop.
05:44 This brings us to the end of this spoken tutorial on iterative calculations using Scilab.
05:50 Spoken Tutorials are part of the Talk to a Teacher project, supported by the National Mission on Education through ICT.
05:57 More information on the same is available at the following link [1].
06:00 Thanks for joining.Good bye.

Contributors and Content Editors

Gaurav, PoojaMoolya, Sandhya.np14, Sneha