Octave教程一:基本操作
我使用的是Octave4.2.0版本,运行命令行程序。
代码块
标准octave代码:
GNU Octave, version 4.2.1
Copyright (C) 2017 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. For details, type 'warranty'.
Octave was configured for "x86_64-w64-mingw32".
Additional information about Octave is available at http://www.octave.org.
Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html
Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.
octave:1> 5+6
ans = 11
octave:2> 2 ^3
ans = 8
octave:3> 1 == 2 %false
ans = 0
octave:4> 1 ~= 2
ans = 1
octave:5> 1 && 0
ans = 0
octave:6> 1 && 4
ans = 1
octave:7> 1 || 0
ans = 1
octave:8> xor (1,0)
ans = 1
octave:9> PS1('>> ');
>>
>>
>> a = 3
a = 3
>> a = 3;
>> a
a = 3
>> b = 'hello';
>> b
b = hello
>> c = (4>=2);
>> c
c = 1
>>
>> a = pi;
>> a
a = 3.1416
>> disp(a);
3.1416
>> disp(sprintf('2 decimals: %0.2f',a))
2 decimals: 3.14
>> disp(sprintf('2 decimals: %0.6f',a))
2 decimals: 3.141593
>> a
a = 3.1416
>> format long
>> a
a = 3.14159265358979
>> format short
>> a
a = 3.1416
>>
>>
>> A = [1 2;3 4;5 6]
A =
1 2
3 4
5 6
>> A = [1 2;
> 3