Difference between revisions of "Scilab/C2/Scripts-and-Functions/Bengali"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with ' নমস্কার বন্ধুগণ|scilab -এর script এবং function -এর ওপর এই স্পোকেন টিউটোরিয়ালটিতে…')
 
Line 1: Line 1:
 +
{| border = 1
  
নমস্কার বন্ধুগণ|scilab -এর script এবং function -এর ওপর এই স্পোকেন টিউটোরিয়ালটিতে আপনাদের স্বাগত জানাই|
+
|'''Time'''
প্রথমেই শুরু করা যাক scilab -এ ফাইল ফর্মাট -এর ওপর একটি সংক্ষিপ্ত উপস্থাপনাকে দিয়ে|
+
  
যখন কতগুলি কমান্ডসকে  একসঙ্গে কার্যকর করতে হয়  , তখন সেগুলি বা সেই statements গুলিকে scilab এডিটর -এর সাহায্যে একটি ফাইল -এ লেখা অনেক বেশী সুবিধাজনক|এইগুলিকে স্ক্রিপ্ট ফাইলস বলে|
+
|'''Narration'''
স্ক্রিপ্ট ফাইল -এ লিখিত  কমান্ডগুলিকে কার্যকর বা সম্পাদন করতে হলে স্ক্রিপ্ট ফাইল-এর নাম দিয়ে exec ফাংশন ব্যবহার করা যেতে পারে|
+
এই ফাইলগুলির একটি extension থাকে  .sce বা .sci |এবং এটি নির্ভর করে ফাইল -এর content বা উপাদানের ওপর|
+
যে ফাইলগুলির extension .sci হয় ,সেইগুলির মধ্যে থাকে scilab -এর ফাংশন ,and /or user defined ফাংশনস বা ব্যবহারকারী নির্দিষ্ট ফাংশন এবং তাদের সম্পাদন বা কার্যকর করলে তা function গুলিকে scilab -এর environment বা পরিবেশে load করে|(কিন্তু সেগুলিকে সম্পাদন বা কার্যকর করে না)
+
আবার অন্যদিকে , যে ফাইলগুলির extension .সকে , সেইগুলি scilab function এবং কার্যকারী statements বা executable statements , দুটিই ধারণ করে|
+
তবে এটি মনে রাখবেন যে extension -এর নামকরণের রীতি ,যেমন .sce এবং .sci , এটি কিন্তু কোনো RULE বা  নিয়মের মধ্যে পড়ে না |তবে এটি একটি রীতি যা scilab কমিউনিটির দ্বারা অনুগমন করা হয়|
+
  
চলুন এবারে কম্পিউটার -এ scilab খুলি|
+
|-
কমান্ড প্রম্পট -এর ওপর cd টাইপ করে বর্তমান কাজের নির্দেশিকাটি একবার দেখে নিন |
+
| 00:01
-->cd
+
| নমস্কার বন্ধুগণ|scilab -এর script এবং function -এর ওপর এই স্পোকেন টিউটোরিয়ালটিতে আপনাদের স্বাগত জানাই|
ans  =
+
  
C:\Documents and Settings\cdeep_lap12 
+
|-
 +
| 00:06
 +
|প্রথমেই শুরু করা যাক scilab -এ ফাইল ফর্মাট -এর ওপর একটি সংক্ষিপ্ত উপস্থাপনাকে দিয়ে|
  
 +
|-
 +
| 00:12
 +
|যখন কতগুলি কমান্ডসকে একসঙ্গে কার্যকর করতে হয় , তখন সেগুলি বা সেই statements গুলিকে scilab এডিটর -এর সাহায্যে একটি ফাইল -এ লেখা অনেক বেশী সুবিধাজনক|
  
 +
|-
 +
| 00:21
 +
|এইগুলিকে স্ক্রিপ্ট ফাইলস বলে|
  
এবারে scilab কনসল উইন্ডো টাস্ক বার-এ গিয়ে এডিটর option -এ ক্লিক করুন scilab এডিটর খোলবার জন্যে |
+
|-
আমি আগে থেকেই ফাইল-এ কমান্ড টাইপ করে save করেছি helloworld.sce নামে|তাই এখন আমি ফাইলটি খুলবো ফাইল-এর শর্টকাট আইকন open করে|
+
| 00:24
disp("Hello World")
+
|স্ক্রিপ্ট ফাইল -এ লিখিত কমান্ডগুলিকে কার্যকর বা সম্পাদন করতে হলে স্ক্রিপ্ট ফাইল-এর নাম দিয়ে exec ফাংশন ব্যবহার করা যেতে পারে|
a=1; b=2; c=a+b;
+
d=a+b+c;
+
disp(d)
+
disp("Goodbye World")
+
  
আপনি নতুন ফাইল-এ কমান্ডগুলি টাইপ করে , ফাইল মেনুতে গিয়ে ফাইলটিকে বর্তমান কাজের নির্দেশিকাতে save করতে পারেন HelloWorld.sce নামে|
+
|-
এটা মনে রাখবেন যে ফাইল নামের মধ্যে কোনো space থাকবে না|
+
| 00:34
এরপর scilab এডিটর মেনুবার এ execute button -এ যান এবং scilab option -এ load -এ সেলেক্ট করুন|
+
|এই ফাইলগুলির একটি extension থাকে .sce বা .sci |
এরফলে ফাইলটি scilab কনসল-এ load হয়ে যাবে|
+
scilab কনসোলে ফাইলটি load হবার পর যে output -টি স্ক্রিপ্ট থেকে পাওয়া যাবে, তা আপনি নিম্নলিখিতটিতে  দেখতে পাচ্ছেন---
+
  
-->disp("Hello World")
+
|-
   
+
| 00:42
  Hello World 
+
| এবং এটি নির্ভর করে ফাইল -এর content বা উপাদানের ওপর|
 
+
--> a=1; b=2; c=a+b;
+
 
+
--> d=a+b+c;
+
 
+
--> disp(d)
+
 
+
    6. 
+
 
+
--> disp("Goodbye World")
+
 
+
  Goodbye World
+
  
তাহলে এটিতে কমান্ডস এবং এক একটি কমান্ডের  ফল স্বরূপ যে output , তা উভয়েই আছে|
+
|-
এবারে এডিটর-এ গিয়ে a -এর মূল্য বা value পরিবর্তন করে 5 করুন|ফাইল মেনুতে যান, আবার save সেলেক্ট করুন এবং এটিকে বন্ধ করুন|
+
| 00:51
আমার আবার scilab interpreter থেকে স্ক্রিপ্টকে সরাসরি সম্পাদন বা কার্যকর করতে পারি exec কমান্ডের সাহায্যে|
+
|এবং তাদের সম্পাদন বা কার্যকর করলে তা function গুলিকে scilab -এর environment বা পরিবেশে load করে|(কিন্তু সেগুলিকে সম্পাদন বা কার্যকর করে না)
  
-->exec("Hello World.sce")
+
|-
 +
| 01:00
 +
| files having the '''.sce''' extension can contain Scilab function and User defined functions.
  
exec কমান্ডটি ব্যবহারের স্ক্রিপ্ট ফাইলটি একই output দিছে---
+
|-
 +
| 01:08
 +
|Please remember that the convention of naming the extension as .sce and .sci are not rules but a convention followed by the scilab community.
  
-->disp("Hello World")
+
|-
 +
|01:21
 +
|চলুন এবারে কম্পিউটার -এ scilab খুলি|
  
Hello World 
+
|-
 +
|01:27
 +
|Check on the present working directory by typing the command '''pwd''' on the command prompt.
  
-->a=5; b=2; c=a+b;
+
|-
-->d=a+b+c;
+
| 01:35
-->disp(d)
+
|এবারে scilab কনসল উইন্ডো টাস্ক বার-এ গিয়ে এডিটর option -এ ক্লিক করুন scilab এডিটর খোলবার জন্যে |
  
    14.  
+
|-
 +
| 01:49
 +
|আমি আগে থেকেই ফাইল-এ কমান্ড টাইপ করে save করেছি helloworld.sce নামে|তাই এখন আমি ফাইলটি খুলবো ফাইল-এর শর্টকাট আইকন open করে|
  
-->disp("Goodbye World")
+
|-
 +
| 02:03
 +
|Select helloworld.sce file and click on Open.
  
Goodbye World
+
|-
 +
| 02:10
 +
|You may type the commands in the new file and save this file to the current working directory as helloworld.sce through the File menu.
  
 +
|-
 +
| 02:20
 +
|Go to Execute button on the scilab editors menu bar and select Load into Scilab option.
  
চলুন এবারে function নিয়ে আলোচনা করি|
+
|-
function -এর ব্যাখ্যা শুরু হয় function দিয়ে এবং শেষ হয় keyword endfunction দিয়ে|
+
|02:29
 +
|This will load the file into  scilab console.
  
স্সিলাব এডিটর ব্যবহার করে আমি আগে থেকেই function save করেছি  function.sci file -|
+
|-
function -এর ব্যাখ্যা করা হয়েছে যেমনটি আপনি দেখতে পাচ্ছেন---
+
|02:34
 +
|After loading the file on the  console the script produces the output as you see.
  
function [degrees] = radians2degrees(radians)
+
|-
  degrees = radians*(180/%pi);
+
|02:43
  endfunction
+
|It contains both the commands and the resulting output for the respective commands.  
  
এখানে radians2degrees নামক function -এ degree হল output parameter এবং radians হল input parameter |
+
|-
এবারে Execute মেনু option ব্যবহার করে আমি এই function -টি লাদ করব scilab -এ|
+
|02:49
এটিকে আবার exec কমান্ড ব্যবহার করেও load করা যায়|
+
|Now change the value of a to 1.
  
-->exec functions.sci
+
|-
 +
|02:55
 +
|In the editor, go to the File menu and click on Save.
  
function -টি এখন scilab কনসোলে load হয়ে গেছে|
+
|-
-->function [degrees] = radians2degrees(radians)
+
| 03:02
-->  degrees = radians*(180/%pi);
+
|We can also execute the script directly from the scilab interpreter using the '''exec''' command and giving the path to the script file as:
-->endfunction
+
  
   
+
|-
একবার function -টি load হয়ে গেলে scilab -এর অন্যান্য function -এর মত এটিকেও ব্যবহার করা যেতে পারে শর্ত বা arguments গুলিকে ওই function -এ পাঠিয়ে|
+
| 03:12
এখানে % সাইনটি দেখুন এবং এর ব্যবহার মনে করে দেখুন|
+
| exec into brackets into double quotes helloworld.sce, that is the file name, and press Enter.
  
চলুন আমরা এবারে radians2degrees(%pi/2) এবং radians2degrees(%pi/4)-এর মূল্য বের করি|
+
|-
 +
| 03:31
 +
| The script file produces a similar output with the use of '''exec''' function.
  
 +
|-
 +
| 03:37
 +
| Let us now talk about '''functions'''.
  
-->radians2degrees(%pi/2)
+
|-
  ans  =
+
| 03:39
 +
|A function definition starts with the keyword '''function''' and ends with the keyword '''endfunction'''.
  
    90.
+
|-
 +
| 03:46
 +
| I have already saved a function file in function.sci, using the scilab editor.  
  
-->radians2degrees(%pi/4)
+
|-
  ans  =
+
| 03:57
 +
|I will open that file.
  
    45.
+
|-
 +
| 04:03
 +
|As you see, the function is defined here.
  
scilab -এর একটি আকর্ষনীয় বৈশিষ্ট্য হল যে আপনি যেকোনো function -এর নম্বরকে define বা ব্যাখ্যা করতে পারেন একটি মাত্র বা single  .sci  ফাইল -এ |
+
|-
এটি করার সময় দিয়া করে মনে রাখবেন যে সমস্ত variables , যা function -এ define বা ব্যাখ্যা করা হয়েছে ,সেইগুলি by default স্থানীয় বা লোকাল|এবং variables গুলির scope বা ব্যাপ্তি একটি নির্দিষ্ট function -এ শেষ হয় function সংঘাথের্র অর্থাৎ  definition -এর end function keyword দিয়ে|
+
| 04:08
এই বৈশিষ্ট্যের একটি সুবিধা হল যে আমরা বিভিন্ন function -এ একই variable বা পরিবর্তনশীল নাম দেখতে পাচ্ছি|
+
|In these, '''degrees''' is the output parameter and '''radians''' is the input parameter.
এই variables -গুলি কখনই একসঙ্গে মিশে যেতে পারে না, যদি না আমরা global option ব্যবহার করি|
+
Global variable সম্পর্কে বিশদে জানতে হলে help global টাইপ করুন এবং সেই সম্পর্কে যাবতীয় তথ্য দেখুন|
+
  
এটি মনে রাখবেন যে function -এর মধ্যে যদি কোনো variables কে দেখতে হয়, বা watch বা monitor করতে হয় ,তবে 'disp 'লেখা প্রয়োজনীয়|
+
|-
function ফাইল-এর মধ্যে আপনি নিজেই দেখতে পারেন semicolon (;) ব্যবহারের ফলাফল, অর্থাৎ statement -এর শেষে semicolon (;) দিলে তার ফলাফল কি হয় তা আপনি নিজেই দেখতে পারবেন|
+
| 04:21
এটি কে আবার আপনি disp ("---"statement ) লিখেও দেখতে পারেন|
+
|To the function name '''radians2degrees'''.
  
 +
|-
 +
| 04:26
 +
|I will  load this function in Scilab, using the Execute menu option.
  
Inline Functions :--
+
|-
 +
| 04:40
 +
| The function is now loaded in the scilab console.
  
function গুলি হল code -এর ছিন্নাংশ বা বিভাগ, যেগুলিতে সুন্দর ভাবে input এবং output  ব্যাখ্যা করা আছে আর সেইসঙ্গে স্থানীয় বা লোকাল variables -ও আছে|
+
|-
function কে ব্যাখ্যা করার একটি সহজ উপায় হল 'deff ' কমান্ডটির ব্যবহার|
+
| 04:44
scilab  inline function -এর সৃষ্টিতে অনুমতি প্রদান করে এবং সেটি বিশেষ ভাবে ব্যবহারযোগ্য বা useful , যখন function -টির body ছোট হয়|
+
|It can also be loaded  using the '''exec''' command.
এটি function deff () -এর সাহায্যে করা যেতে পারে| এটি দুই শ্রেনীর parameter -কে গ্রহণ করে |প্রথম শ্রেণীটি function -এর পদ্ধতি বা interface কে ব্যাখ্যা করে , এবং দ্বিতীয় শ্রেণীটি function -এর statement কে ব্যাখ্যা করে|
+
deff কমান্ড scilab -এ function -কে ব্যাখ্যা করে এবং load করে|
+
deff কমান্ডকে ব্যবহার করে ব্যাখ্যা করা function কে execute মেনু option দিয়ে load করবার কোনো প্রয়োজন নেই|
+
চলুন একটি উদাহরণ দেখি এই ধারনাটিকে ব্যাখ্যা করবার জন্যে ----
+
  
deff("[radians] = degrees2radians(degrees)","radians = degrees*(%pi/180)")
+
|-
 +
| 04:47
 +
|Once a function is loaded, it can be called like any other Scilab function by passing specific arguments to that function.
  
তাহলে আগে যা উল্লেখ করা হয়েছে , এখানে তা দেখা যাচ্ছে|অর্থাৎ প্রথম শ্রেণীটি function -এর পদ্ধতি বা interface কে ব্যাখ্যা করে, এবং দ্বিতীয় শ্রেণীটি function -এর statement -কে ব্যাখ্যা করে|
+
|-
আমরা এটিকে সরাসরি ব্যবহার করতে পারি degrees2radians(90) এবং  degrees2radians(45) -এর value বা মূল্য বের করবার জন্যে|
+
| 04:56
 +
|Make a mental note of the percent sign (%) and recall the reason of its use.
  
-->degrees2radians(90)
+
|-
  ans  =
+
| 05:02
 +
|Now let us find values for radians2degrees of %pi/2 and radians2degrees of (%pi/4).
  
    1.5707963  
+
|-
 +
| 05:17
 +
|percent pi/2 and radians2degrees  percent pi by 4 (%pi/4).
  
-->degrees2radians(45)
+
|-
  ans  =
+
| 05:28
 +
|Now we will see a function with more than one input and output arguments.
  
    0.7853982
+
|-
 +
| 05:33
 +
|This function will take '''polar coordinates''' as input argument and returns '''rectangular coordinates''' as output arguments.  
  
একটি function কেবলমাত্র নিজের মধ্যেকার অন্যান্য function গুলিকে বর্ণনা করে না, তার সাথে  নিজেরও (ITSELF ) বর্ণনা করে |
+
|-
এটি হল "recursive "function -এর বর্ণনা|যখন কোনো function লেখা হয় পূর্ণসংখ্যার factorial গণনার জন্যে, তখন এটির ব্যবহার প্রয়োজনীয়|
+
| 05:44
 +
|I will open the file which I have already typed.
  
চলুন আলোচনাটি সম্প্রসারিত করি scilab -এ ফাইল ফর্মাট পর্যন্ত |
+
|-
 +
| 05:51
 +
|Here you can see, '''x''' and '''y''' are the output parameters and '''r''' and '''theta''' are the input parameters to the function '''polar2rect'''.
  
আগেই উল্লেখ করা হয়েছে যে scilab -এ দুধরনের ফাইল ফর্মাট থাকে ---একটি হল SCE ফাইল ফর্মাট এবং অপরটি হল স্কি ফাইল ফর্মাট|
+
|-
যে ফাইল গুলির extension .sce সেইগুলি হল স্ক্রিপ্ট ফাইল , যেগুলি ধারণ করে সেই সব scilab কমান্ডস , যেগুলি ব্যবহার করা হয়  interactive scilab session -এর somoy|
+
| 06:06
aeiguli comment line -এর অন্তরভুক্ত হতে পারে যা ব্যবহার করা যায় function -এর উপস্থাপনার ক্ষেত্রে এবং এইগুলি আবার EXEC কমান্ডও  ব্যবহার করতে পারে স্ক্রিপ্টকে সম্পাদনা করার জন্যে|
+
|I will load this function in scilab using the '''exec''' option.
  
আবার যে ফাইল উলির এক্ষ্তেন্সিওন .sci , সেইগুলি হল সেই function ফাইল যা শুরু হয় function statement দিয়ে |একটি single .sci ফাইল-এ একাধিক function -এর ব্যাখ্যা থাকতে পারে , যেগুলিতে আবার যে কোনো সংখ্যার silab statement থাকতে পারে যা function arguments -এর ওপর অথবা গণনার পরে যে output variables  পাওয়া যায় , তার ওপর কার্য করে|
+
|-
তাহলে এর সঙ্গেই আমাদের scilab ও function -এর ওপর এই স্পোকেন টিউটোরিয়ালটি শেষ হল|scilab -এর আরো অনেক functions আছে , যেগুলির সম্পর্কে অন্যান্য স্পোকেন টিউটোরিয়াল-এ আলোচনা করা হয়েছে|এর জন্যে scilab link -এ নজর রাখুন|
+
| 06:21
স্পোকেন টিউটোরিয়ালটি হল Talk to a Teacher project, -এর অংশ বিশেষ যা National Mission on Education through ICT -এর দ্বারা সহায়ক|
+
|Once the function is loaded, we need to call the function. This function requires two input arguments and two output arguments.
এই বিষয়ে আরো তথ্য পাওয়া যাবে নিম্নলিখিত link -এ ------
+
  
http://spoken-tutorial.org/NMEICT-Intro
+
|-
 +
| 06:31
 +
|Therefore r = 2,
  
আমি নীলাঞ্জনা চৌধুরী মুম্বাই থেকে আপনাদের অসংখ্য ধন্যবাদ জানাই আমাদের সঙ্গে থাকবার জন্যে| নমস্কার|
+
|-
 +
| 06:37
 +
|theta = 45;
 +
 
 +
|-
 +
| 06:44
 +
|and now we will call it x1 comma y1, output parameters, is equal to function name '''polar2rect into bracket r comma theta''' and press Enter.
 +
 
 +
|-
 +
| 07:25
 +
|You will see the value of x1 and y1.
 +
 
 +
|-
 +
| 07:29
 +
|One of the interesting features of Scilab is, you can define any number of functions in a single '''.sci''' file.
 +
 
 +
|-
 +
| 07:38
 +
|While doing this, please remember that by default all the variables defined in a function are local, the scope of these variables used in a particular function ends with the '''endfunction''' keyword of the function definition.
 +
 
 +
|-
 +
| 07:55
 +
|Advantage of this feature is that, we can use same variable names in different function.
 +
 
 +
|-
 +
| 08:05
 +
|These variables won't get mixed up unless we use the global option.
 +
 
 +
|-
 +
| 08:10
 +
|To know more about the global variables, type '''help global'''.
 +
 
 +
|-
 +
| 08:18
 +
|Please note that if any variable is to be "watched" or monitored inside a function then '''disp''' is required.
 +
 
 +
|-
 +
| 08:26
 +
|Inside a function file, you can check for yourself the effect of putting a semicolon ( ; ) at the end of a statement.
 +
 
 +
|-
 +
| 08:34
 +
|Also check this for '''disp''' statements.
 +
 
 +
|-
 +
| 08:38
 +
|'''Inline Functions''':
 +
 
 +
|-
 +
| 08:39
 +
|Functions are segments of code that have well defined input and output as well as local variables.
 +
 
 +
|-
 +
| 08:46
 +
|The simplest way to define a function is by using the command `'''deff'''. 
 +
 
 +
|-
 +
| 08:53
 +
|Scilab allows the creation of in-line functions and are especially useful when the body of the function is short.
 +
 
 +
|-
 +
| 09:02
 +
|This can be done with the help of the function deff().
 +
 
 +
|-
 +
| 09:07
 +
|It takes two string parameters.
 +
 
 +
|-
 +
| 09:10
 +
|The first string defines the interface to the function and the second string defines the statements of the function.
 +
 
 +
|-
 +
| 09:19
 +
|The '''deff''' command defines the function in the Scilab and also loads it.
 +
 
 +
|-
 +
| 09:26
 +
|There is no need to load the function defined by using '''deff''' command explicitly through execute menu option .
 +
 
 +
|-
 +
| 09:34
 +
|Let us see an example to illustrate this concept:
 +
 
 +
|-
 +
| 09:41
 +
|I will open a file '''inline.sci''' where I have written the inline function.
 +
 
 +
|-
 +
| 09:51
 +
|I will resize the editor window.
 +
 
 +
|-
 +
| 09:57
 +
|As mentioned earlier, the first string defines the function declaration and the second string defines the statements of the function.
 +
 
 +
|-
 +
| 10:13
 +
|We will load this function in Scilab editor and use it to find the values of degrees2radians of 90 and degrees2radians of 45.
 +
 
 +
|-
 +
| 10:54
 +
|A function should call, not just other functions within itself, but also '''itself'''.
 +
 
 +
|-
 +
| 11:00
 +
|This is '''recursive''' calling of a function.
 +
 
 +
|-
 +
| 11:03
 +
|This is required, for example, when writing a function to calculate the factorial of an integer.
 +
 
 +
|-
 +
| 11:10
 +
|Let us extend the discussion on file formats in Scilab:
 +
 
 +
|-
 +
| 11:14
 +
|As mentioned earlier Scilab uses two types of file formats, namely the '''.sce''' file format and the '''.sci''' file formats.
 +
 
 +
|-
 +
| 11:23
 +
|The files with the '''.sce''' file extension are the script files which contain the Scilab commands that you enter during an interactive kind of Scilab session.
 +
 
 +
|-
 +
| 11:35
 +
|They can comprise comment lines utilized in documenting the function and they can also use the command '''exec''' to execute the script.
 +
 
 +
|-
 +
| 11:52
 +
|The files with the '''.sci''' file extension are the function files that start with the function statement.
 +
 
 +
|-
 +
| 12:00
 +
|A single '''.sci''' file can have multiple function definitions which themselves contain any number of Scilab statements, that perform operations on the function arguments or on the output variables, after they have been evaluated.
 +
 
 +
|-
 +
| 12:20
 +
|This brings us to the end of this spoken tutorial on '''Scripts and Functions''' in Scilab.
 +
 
 +
|-
 +
| 12:25
 +
|There are many other functions in Scilab which will be covered in other spoken tutorials.
 +
 
 +
|-
 +
| 12:31
 +
|Keep watching the Scilab links.
 +
 
 +
|-
 +
| 12:33
 +
|This spoken tutorial: has been created by the Free and Open Source Software in Science and Engineering Education (FOSSEE).
 +
 
 +
|-
 +
| 12:40
 +
|More information on the FOSSEE project could be obtained from http://fossee.in or http://scilab.in
 +
 
 +
|-
 +
| 12:50
 +
|Supported by the National Mission on Eduction through ICT, MHRD, Government of India.
 +
 
 +
|-
 +
| 12:56
 +
|For more information, visit: http://spoken-tutorial.org/NMEICT-Intro.
 +
 
 +
|-
 +
| 13:06
 +
|This is Anuradha Amrutkar from IIT Bombay. signing off.
 +
 
 +
|-
 +
| 13:10
 +
|Thanks for joining us. Goodbye.

Revision as of 17:47, 3 March 2017

Time Narration
00:01 scilab -এর script এবং function -এর ওপর এই স্পোকেন টিউটোরিয়ালটিতে আপনাদের স্বাগত জানাই|
00:06
00:12
00:21
00:24
00:34
00:42
00:51 (কিন্তু সেগুলিকে সম্পাদন বা কার্যকর করে না)
01:00 files having the .sce extension can contain Scilab function and User defined functions.
01:08 Please remember that the convention of naming the extension as .sce and .sci are not rules but a convention followed by the scilab community.
01:21
01:27 Check on the present working directory by typing the command pwd on the command prompt.
01:35
01:49 তাই এখন আমি ফাইলটি খুলবো ফাইল-এর শর্টকাট আইকন open করে|
02:03 Select helloworld.sce file and click on Open.
02:10 You may type the commands in the new file and save this file to the current working directory as helloworld.sce through the File menu.
02:20 Go to Execute button on the scilab editors menu bar and select Load into Scilab option.
02:29 This will load the file into scilab console.
02:34 After loading the file on the console the script produces the output as you see.
02:43 It contains both the commands and the resulting output for the respective commands.
02:49 Now change the value of a to 1.
02:55 In the editor, go to the File menu and click on Save.
03:02 We can also execute the script directly from the scilab interpreter using the exec command and giving the path to the script file as:
03:12 exec into brackets into double quotes helloworld.sce, that is the file name, and press Enter.
03:31 The script file produces a similar output with the use of exec function.
03:37 Let us now talk about functions.
03:39 A function definition starts with the keyword function and ends with the keyword endfunction.
03:46 I have already saved a function file in function.sci, using the scilab editor.
03:57 I will open that file.
04:03 As you see, the function is defined here.
04:08 In these, degrees is the output parameter and radians is the input parameter.
04:21 To the function name radians2degrees.
04:26 I will load this function in Scilab, using the Execute menu option.
04:40 The function is now loaded in the scilab console.
04:44 It can also be loaded using the exec command.
04:47 Once a function is loaded, it can be called like any other Scilab function by passing specific arguments to that function.
04:56 Make a mental note of the percent sign (%) and recall the reason of its use.
05:02 Now let us find values for radians2degrees of %pi/2 and radians2degrees of (%pi/4).
05:17 percent pi/2 and radians2degrees percent pi by 4 (%pi/4).
05:28 Now we will see a function with more than one input and output arguments.
05:33 This function will take polar coordinates as input argument and returns rectangular coordinates as output arguments.
05:44 I will open the file which I have already typed.
05:51 Here you can see, x and y are the output parameters and r and theta are the input parameters to the function polar2rect.
06:06 I will load this function in scilab using the exec option.
06:21 Once the function is loaded, we need to call the function. This function requires two input arguments and two output arguments.
06:31 Therefore r = 2,
06:37 theta = 45;
06:44 and now we will call it x1 comma y1, output parameters, is equal to function name polar2rect into bracket r comma theta and press Enter.
07:25 You will see the value of x1 and y1.
07:29 One of the interesting features of Scilab is, you can define any number of functions in a single .sci file.
07:38 While doing this, please remember that by default all the variables defined in a function are local, the scope of these variables used in a particular function ends with the endfunction keyword of the function definition.
07:55 Advantage of this feature is that, we can use same variable names in different function.
08:05 These variables won't get mixed up unless we use the global option.
08:10 To know more about the global variables, type help global.
08:18 Please note that if any variable is to be "watched" or monitored inside a function then disp is required.
08:26 Inside a function file, you can check for yourself the effect of putting a semicolon ( ; ) at the end of a statement.
08:34 Also check this for disp statements.
08:38 Inline Functions:
08:39 Functions are segments of code that have well defined input and output as well as local variables.
08:46 The simplest way to define a function is by using the command `deff.
08:53 Scilab allows the creation of in-line functions and are especially useful when the body of the function is short.
09:02 This can be done with the help of the function deff().
09:07 It takes two string parameters.
09:10 The first string defines the interface to the function and the second string defines the statements of the function.
09:19 The deff command defines the function in the Scilab and also loads it.
09:26 There is no need to load the function defined by using deff command explicitly through execute menu option .
09:34 Let us see an example to illustrate this concept:
09:41 I will open a file inline.sci where I have written the inline function.
09:51 I will resize the editor window.
09:57 As mentioned earlier, the first string defines the function declaration and the second string defines the statements of the function.
10:13 We will load this function in Scilab editor and use it to find the values of degrees2radians of 90 and degrees2radians of 45.
10:54 A function should call, not just other functions within itself, but also itself.
11:00 This is recursive calling of a function.
11:03 This is required, for example, when writing a function to calculate the factorial of an integer.
11:10 Let us extend the discussion on file formats in Scilab:
11:14 As mentioned earlier Scilab uses two types of file formats, namely the .sce file format and the .sci file formats.
11:23 The files with the .sce file extension are the script files which contain the Scilab commands that you enter during an interactive kind of Scilab session.
11:35 They can comprise comment lines utilized in documenting the function and they can also use the command exec to execute the script.
11:52 The files with the .sci file extension are the function files that start with the function statement.
12:00 A single .sci file can have multiple function definitions which themselves contain any number of Scilab statements, that perform operations on the function arguments or on the output variables, after they have been evaluated.
12:20 This brings us to the end of this spoken tutorial on Scripts and Functions in Scilab.
12:25 There are many other functions in Scilab which will be covered in other spoken tutorials.
12:31 Keep watching the Scilab links.
12:33 This spoken tutorial: has been created by the Free and Open Source Software in Science and Engineering Education (FOSSEE).
12:40 More information on the FOSSEE project could be obtained from http://fossee.in or http://scilab.in
12:50 Supported by the National Mission on Eduction through ICT, MHRD, Government of India.
12:56 For more information, visit: http://spoken-tutorial.org/NMEICT-Intro.
13:06 This is Anuradha Amrutkar from IIT Bombay. signing off.
13:10 Thanks for joining us. Goodbye.

Contributors and Content Editors

Kaushik Datta