Scilab/C2/Iteration/Gujarati
From Script | Spoken-Tutorial
Time' | Narration
|
00.02 | સાઈલેબનો ઉપયોગ કરી ઈટરેટીવ ગણતરી પરના સ્પોકન ટ્યુટોરીયલમાં તમારું સ્વાગત છે. |
00.07 | હું Mac ઓપરેટીંગ સીસ્ટમ ઉપર સાઈલેબ આવૃત્તિ 5.2 વાપરી રહ્યી છું. |
00.11 | પરંતુ આ ગણતરીઓ અન્ય આવૃત્તિઓમાં અને સાઈલેબ જે Linux અને Windows ઉપર રન થાય છે તેમાં પણ કામ કરવું જોઈએ. |
00.18 | હું iteration.sce માં ઉપલબ્ધ કોડનો ઉપયોગ કરીશ. |
00.23 | મેં આ ફાઈલ સાઈલેબ એડિટરની મદદથી ખોલી છે, જે મેં એડિટર તરીકે ઉપયોગ કરવા માટે યોજ્યું હતું. |
00.29 | ચાલો કોલોન ઓપરેટરની મદદથી વેક્ટર બનાવીએ, i ઇકવલ ટુ 1 કોલોન 5 |
00.38 | તે 1 ઇન્ક્રીમેન્ટ સાથે, 1 થી 5 માટે વેક્ટર બનાવે છે. |
00.42 | આ આદેશમાં, i એ 1 કોલોન 2 કોલોન 5 સમાન છે |
00.52 | આપણે જોઈએ છીએ કે 2 નું મધ્યનું આર્ગ્યુંમેન્ટ ઇન્ક્રીમેન્ટ સૂચવે છે. |
00.56 | 1 એ પ્રથમ આર્ગ્યુંમેન્ટ છે જ્યાંથી વેક્ટર શરૂ થાય છે. હું 5 થી આગળ ન જઈ શકું. |
01.01 | જોકે, તે 5 સમાન હોઈ શકે છે. |
01.04 | નોંધ લો કે, જો અંતિમ આર્ગ્યુંમેન્ટ 6 થી બદલાય છે તો પરિણામ સમાન જ રહે છે. |
01.10 | આ વર્તણૂક સમજાવવા માટે મુશ્કેલ નથી. |
01.13 | શું તમે સોચી શકો છે કે આ શા માટે થાય છે? |
01.16 | We will now demonstrate the use of the for statement to perform iterative calculations.
for i ઇકવલ ટુ 1 કોલોન 2 કોલોન 7 disp i for લુપનો અંત. |
01.29 | I will cut this paste in scilab console press enter. |
01.35 | 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.53 | The number of times the iterations take place is known as priori in for loops. |
01.57 | 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.19 | 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.31 | 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.41 | Note that "i is equal to 2" statement uses the "equal to" sign twice. |
02.46 | This is the standard way to compare the equality in programming languages. |
02.51 | 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.11 | 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.33 | 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.47 | This opens the scilab help browser. |
03.52 | We see that the help is available under the option less. |
03.56 | So now after closing this we type help less |
04.07 | We see the required help instructions here. I will close this. |
04.12 | 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.25 | 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.45 | We have spent quite a bit of time explaining the for loop. |
04.48 | Let us now move on to the while loops. |
04.51 | The while statement allows us to perform a loop when a boolean expression is true |
04.56 | At the beginning of the loop, if the expression is true, |
04.59 | 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.40 | 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.51 | 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. |