octave移动数据

 A = [1 2;3 4; 5 6]
A =

   1   2
   3   4
   5   6

size()返回矩阵的大小

size(A)
ans =

   3   2
返回A的行数
size(A,1) ans = 3

返回A的列数

size(A,2)
ans =  2

返回v的最大维数

>> v = [1 2 3 4]
v =

   1   2   3   4

>> length(v)
ans =  4

返回A的最大维数(A 3*2)

>> length(A)
ans =  3

 

 

文件处理

octave的安装路径

>> pwd
ans = G:\octave\octave-5.1.0-w64

ls显示当前目录下的文件结构

>> ls
 Volume in drive G is 新新加加卷卷
 Volume Serial Number is E45B-C624

 Directory of G:\octave\octave-5.1.0-w64

[.]                    [etc]                  msys2.ico              post-install.bat
[..]                   fc_update.bat          msys2_shell.cmd        README.html
[clang32]              HG-ID                  [notepad++]            [tmp]
[clang64]              [home]                 octave-firsttime.vbs   [usr]
cmdshell.bat           [mingw32]              octave.vbs             [var]
[dev]                  [mingw64]              [opt]
               9 File(s)         40,592 bytes
              14 Dir(s)  239,150,755,840 bytes free

cd进入路径

>> cd C:\Users\22735\Desktop\os
>> pwd
ans = C:\Users\22735\Desktop\os
>> ls
 Volume in drive C has no label.
 Volume Serial Number is A4A1-9EDE

 Directory of C:\Users\22735\Desktop\os

[.]  [..]
               0 File(s)              0 bytes
               2 Dir(s)  67,279,585,280 bytes free

加载数据

load   featureX.dat

load(featureX.dat)

who显示定义的所有变量

>> who
Variables in the current scope:

A    I    a    ans  c    sz   v    w

whos显示更详细的信息

>> whos
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        A           3x2                         48  double
        I           4x4                         32  double
        a           1x1                          8  double
        ans         1x25                        25  char
        c           3x4                         96  double
        sz          1x2                         16  double
        v           1x4                         32  double
        w           1x10000                  80000  double

Total is 10066 elements using 80257 bytes

 

clear删除变量

>> clear I
>> who % I已经不见了
Variables in the current scope: 

A    a    ans  c    sz   v    w

将priceY的前10个数据赋值给v

>> v = priceY(1:10)
v =

   0.134924
   0.065742
   0.863374
   0.139802
   0.677121
   0.654762
   0.141145
   0.228309
   0.789854
   0.451826

将数据存储在硬盘里

>> save hello.txt v;
>> save hello.txt v -ascii; % save as text(ASCII)ASCII格式

octave移动数据

clear 删除所有的变量

>>clear

A(m,n)获取矩阵中特定的值

>> A
A =

   1   2
   3   4
   5   6

  >> A(3,2)
  ans = 6

 

A(m,:)获取第m行的数据

>> A(2,:)
ans =

   3   4

A(:,n)获取第n列的数据

>> A(:,1)
ans =

   1
   3
   5

:冒号代表该行或者该列所有的数据

显示A矩阵第1行和第3行的数据

>> A([1 3], :)
ans =

   1   2
   5   6

按行列替换元素

>> A(:,2) = [10;11;12]
A =

    1   10
    3   11
    5   12

添加列向量B = [A , [column vector]]

>> A = [A,[100; 101; 102]]
A =

     1    10   100
     3    11   101
     5    12   102

将A作为列向量显示

>> A(:)
ans =

     1
     3
     5
    10
    11
    12
   100
   101
   102

结合两个矩阵C = [A B]

>>  B = [A,A]
B =

     1    10   100     1    10   100
     3    11   101     3    11   101
     5    12   102     5    12   102

竖放置C = [A ; B]

>> B = [A;A]
B =

     1    10   100
     3    11   101
     5    12   102
     1    10   100
     3    11   101
     5    12   102

 

octave移动数据

上一篇:Android基础-BroadCastReceiver全方位解析


下一篇:Android基础-Service全方位解析