You are on page 1of 10

B 1

1.1. GNU OCTAVE


GNU Octave ,
www.gnu.org . GNU Octave
,
( 1.1.)

c 1. 1
(Menu bar).
.
Ao e c 1.1,
Window Reset Default Window Layout.

:
File Browser - ,
.
Workspace - ,
.
.
Command History -
Workspace .
,
:
Command Window - .
.
Editor
Command Window ( Notepad-o).
Documentation

,
Command window:
,
(>>).

<Enter>.
.
()
(>>) .
1.2.
GNU Octave, help- .
Documentation.
Help ,

.
Help ,

.
,
:
>> help
help .
>> help *
2

>> help i
>> help sqrt
1.3.
GNU Octave
.
o , ,
.
11 .
.
GNU Octave . ,
, , .
GNU Octave ,
.
. GNU Octave
.
. GNU Octave
.
.
GNU Octave .
,
. ,

.
1:
>> y=2x
>>>parse error:
syntax error
>>> 2x
^
GNU Octave
(string).
ASCII ,
,
'x' x.

2: .
>> rec='student'
rec =student
>> rec1="student"
rec1 = student
3: .
>> size(rec)
ans =
1 7
size,
.
: ( 1 7 , .
)
: GNU Octave = .

Ime_promenljive= numerika vrednost ili izraz
, ,
, 31
.
GNU Octave , . x X
.
,
.
.
1.4.

:
( 1. 1).

+
*
/
^

1. 1
4: 2+4-6.
>> 2+4-6
ans = 0
GNU Octave
ans (answer-)
.
1

5: x 2 2 4 .

>> x=2+(2*4-1/pi)
x = 9.6817

je GNU Octave
pi.
6: y 3x , x 32 .
>> x=3^2;
>> y=3*x
y=
27
:
, ; .
.
,
, .
1.5.

. (true) 1
(false) 0 ( 1. 2).

<

>

==
~=

1. 2

7: 5<3.
>> 5<3
ans =
0
8: 5<(7= =8).
>> 5<(7= =8)
ans =
0
= = =
>> 5<(7=8)
??? 5<(7=8)
|
Error: ")" expected, "=" found.
: = = =,
= = , = .
7 8 , , .
0 5 0 0.
1.6.

&
|




1. 3

1
1
0
0

B
1
0
1
0


&
|B
~
0
1
1
0
0
1
1
0
1
1
0
0
1. 4

1.7.

.
GNU Octave
1.5.
,
.
abs( )
sqrt( )
sin( )
cos( )
tan( )
cot( )
exp( )
log( )
log10( )



10
1. 5

11: sin

>> sin(pi/4)
ans =
0.7071
12: x 5 y 59
z ln y x .

>> x=5;
>> y=59;
>> z=log(y)+sqrt(x)
z=6.0775
: x y
, ;
13:
x2 2x 3 .
>> % Kvadratna jednaina je oblika ax^2+bx+c :
>> % Reenja se dobijaju na osnovu formule x1, 2
>> a=1;b=-2;c=-3;
>> koren=sqrt(b^2-4*a*c);

b b 2 4ac
:
2a

>> x1=(-b+koren)/(2*a)
x1 =
3
>> x2=(-b-koren)/(2*a)
x2 =
-1
: % .
14: z log10 x y ,
x=10 y=-20.
>> % x i y su vrednosti promenljivih iz predhodnog primera
>> z=log10(x)+abs(y)
z=
21
: GNU Octave

.

1.8. GNU OCTAVE

ans

eps

i,j
pi
Inf
NaN

, 1
=3.14159265.....
, 1/0 (infinity)
, 0/0 (Not a Number)

-52

1. 6
: GNU Octave
.

.
1.9.

format. ,
.
:

format short
format long
format short e
format long e
format rat

4 , 0,001<x<1000
14 ,
0,001<x<1000
4 format short
15 format long


format short, 4 .
15:
.

>> format long, pi


ans =
3.14159265358979
>> format long e, pi
ans =3.141592653589793e+000
>> format short e, pi
ans =
3.1416e+000
>> format rat, pi
ans =
355/113
>> format short, pi % podrazumevana notacija
ans =
3.1416
:
.
format short, format.

1.10.

clear
clear x
save
save ime
quit , exit
load


x



save
1. 7

:
1. e ili e ?
( e GNU Octave,

x 1 ).
2. a 18.2, b 6.42, c a / b, d 0.5(cb 2a)
a b a d

.
c
abc
2

m d

3. .
4. cos 2

10

x
tgx sin x

x .
2
2tgx
5

You might also like