- •Міністерство освіти і науки, молоді та спорту україни
- •Laboratory Works of Computing and Programming
- •Contents
- •1.2 Base Concepts of Operating Systems
- •1.3 Linux (lubuntu) Operating System
- •1.4 Tasks for Independent Work
- •1.5 Test Questions
- •2 Laboratory work № 2 Word Processor libreoffice.Writer
- •2.1 What Word Processors Can Do
- •2.2 Tasks for Independent Work
- •2.3 Test Questions
- •3 Laboratory work № 3
- •Introduction to the calc spreadsheet
- •3.1 The Basic Opportunities of Spreadsheets
- •3.1.1 Calc’s Environment
- •3.1.2 Calculations in Calc. Creating and Coping Formulas
- •3.2 The Calc charting capability
- •3.3 Tasks for Independent Work
- •4.2 Main Rules of Works in Scilab System
- •Variables
- •Input of vectors (arrays)
- •Input of matrixes
- •Some operations with matrixes with use of the operator ":"
- •Input from keyboard
- •Operators. Expressions use familiar arithmetic operators and precedence rules.
- •Intrinsic scilab Functions
- •Examples of Expressions
- •4.3 Individual Tasks for Laboratory Work
- •4.4 The Tasks for Self-Examination
- •4.5 Test Questions
- •5 Laboratory work № 5
- •5.3.1The plot function
- •5.3.3 Preparing Graphs for Presentation
- •Interactive Plot Editing
- •5.3.4 3D Plotting
- •5.4 Individual Tasks
- •5.6 Test Questions
- •6 Laboratory work № 6 programming in Scilab
- •6.1 Programming in scilab
- •What Happens When You Call a Function
- •Clearing Functions from Memory
- •6.2 Tasks for laboratory work
- •6.3 Example of performance of the laboratory work
- •6.4 Test Questions
- •7 ReferencEs
What Happens When You Call a Function
When you call a function from either the command line or from within another program file, SCILAB parses the function into pseudocode and stores it in memory. This prevents SCILAB from having to reparse a function each time you call it during a session. The pseudocode remains in memory until you clear it using the clear function, or until you quit SCILAB.
Clearing Functions from Memory
You can use clear in any of the following ways to remove functions from the SCILAB workspace.
Syntax |
Description |
clear functionname |
Remove specified function from workspace |
clear functions |
Remove all compiled functions |
clear all |
Remove all variables and functions |
6.2 Tasks for laboratory work
1. Create functions for tasks from laboratory work 3 and call it with different arguments.
2. Create script, which build plots for your task in laboratory work 3.
6.3 Example of performance of the laboratory work
Create functions and write scripts to build plots of functions.
а) - function of one variable;
b) - function y(x) is given parametrically;
c) - function of two variables, surface.
Functions for task:
File f1.m
function y=f1(x)
y=sin(x).*exp(-2*x);
File f2.m
function [x,y]=f2(t)
x=2*cos(t).*sin(4*t);
y=2*sin(4*t).*sin(t);
File f3.m
function [X,Y,Z]=f3(x,y)
[X,Y] = meshgrid(x,y);
Z = X .* exp(-X.^2 - Y.^2);
Scripts for task and results of script work:
File plot_a.m
% script for plots
x=0:0.1:pi; y=f1(x);
plot(x,y,'LineWidth',3)
grid on
The command >> plot_a outputs the plot on fig. 6.1.
Figure 6.1 – plot for task (a)
File plot_b.m
% script for b)
t=0:0.02:2*pi; [x,y]=f2(t);
plot(x,y,'LineWidth',2)
grid on
The command >> plot_b outputs the plot on fig. 6.2.
Figure 6.2 – plot for task (b)
File plot_c.m
% script for surface
x=-2:0.2:2; y=-2:0.2:2;
[X,Y,Z]=f3(x,y);
surf(X,Y,Z)
The command >> plot_c outputs the plot on fig. 6.3.
Figure 6.3 – plot for task (c)
6.4 Test Questions
What kinds of program files can you create in Scilab?
How to create m-file?
What is script?
How to start script file?
What structure has M-function?
How to invoke user function?
What difference between scripts and functions?
What parameters we call dummy parameters?
What parameters are actual?
How actual parameters are passed to function?
7 ReferencEs
Л.М. Дибкова. Інформатика та комп’ютерна техніка. Посібник для студентів. – К.: Видавничий центр “Академія”, 2002. – 592с.
Інформатика. Комп’ютерна техніка. Комп’ютерні технології. Підручник. – К.:Каравела, 2003. – 464 с.
Інформатика: Комп’ютерна техніка. Комп’ютерні технології. Посіб./ За ред. О.І. Пушкаря – К.: Видавничий центр “Академія”, 2001. – 696с.
Ross L. Spencer, INTRODUCTION TO SCILAB. Department of Physics and Astronomy, Brigham Young University, 2000.
Дьяконов В. П. SCILAB 7.*/R2006/R2007: Самоучитель. – М.: ДМК Пресс, 2008. – 768 с.: ил.