zoukankan      html  css  js  c++  java
  • [Machine Learning] Octave Moving data around

    Load data:

    load featuresX.dat

    who: Check how many variables in your current session:

    who

    whos: details about variables:

    whos

    Clear one variable:

    clear M # delete the M variable

    Clear all variables:

    clear

    Save the data into file:

    save hello.mat v # save v variable into a file called hello.mat

    Save as readable with -ascii:

    save hello.txt v -ascii # save as text (ASCII)

    Access one element in Metrix:

    A = [1 2; 3 4; 5 6]
    A(3, 2) # 6

    Access one row/column:

    A(2, :) # ':' means every element along that row/column
    
    # 3 4
    >> A(:, 2) # get second column data
    """
    ans =
    
       2
       4
       6
    """

    Access multi rows/columns:

    >> A([1, 3], :) # get row 1 & 3
    """
    ans =
    
       1   2
       5   6
    """

    Assign one column/row:

    >> A(:, 2) = [10; 11; 12] # assign second column
    """
    A =
    
        1   10
        3   11
        5   12
    """

    Append another column vector to right:

    >> A = [A, [100; 101; 102]]
    A =
    
         1    10   100
         3    11   101
         5    12   102

    Put all element of A into a single vector:

    >> A(:)
    ans =
    
         1
         3
         5
        10
        11
        12
       100
       101
       102

    Concat two matrixs:

    >> A = [1 2; 3 4; 5 6]
    A =
    
       1   2
       3   4
       5   6
    
    >> B = [10 11; 12 13; 14 15]
    B =
    
       10   11
       12   13
       14   15
    
    >> C = [A B]
    C =
    
        1    2   10   11
        3    4   12   13
        5    6   14   15
    
    >> D = [A; B]
    D =
    
        1    2
        3    4
        5    6
       10   11
       12   13
       14   15
  • 相关阅读:
    钢镚开发的第7天
    钢镚儿开发的第六天
    钢镚儿开发的第五天
    钢镚儿开发第三、第四天
    4.18第九周学习进度
    人与神话阅读笔记02
    钢镚儿开发第二天
    热词云
    钢镚儿开发第一天
    [Usaco2006 Mar]Mooo 奶牛的歌声
  • 原文地址:https://www.cnblogs.com/Answer1215/p/13520266.html
Copyright © 2011-2022 走看看