TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Octave

    Create a New Matrix using Octave

    Overview

    In this tutorial, we will learn the steps to Create a New Matrix using GNU Octave.

    Create a New Matrix

    We can create a new matrix or vector with square brackets. We can specify the matrix elements between []. We can use a comma or a space to separate entries in a row, and a semicolon( ; ) or carriage return to separate the rows.
    We can store the matrix in a variable so that we can refer to it later in the script.

    Example

    To create a new matrix with 2 rows and 3 columns.

    Create a New Matrix Octave

    We can end the command with a semicolon(;) to tell Octave not to print the result of the command or the variable.

    In-built Functions

    Octave also provides some in-built functions to create vectors. The rand(row, column) function creates a matrix with random values.

    For example, to create a matric with 3 rows and 4 columns with random elements, we can use the following command:

    >> rand(3,4) 

    By default, each element in the matrix will be set to a value between 0 and 1.

    Rand Octave Function

    The other most used functions to create matrices are:

    • zeros
    • ones

    For example, the function zeros(2) creates a matrix with all elements as zero with two rows and two columns.

    >> a = zeros(2)

    a =

    0    0

    0    0

     

    The function ones(2) creates a matrix with all elements as one with two rows and two columns.

    —

    Octave Tutorials

    GNU Octave Tutorials on this website can be found at:

    https://www.testingdocs.com/octave-tutorial/

    For more information on Octave, visit the official website:

    https://www.gnu.org/software/octave/index

    Related Posts

    Octave Package List

    Octave /

    Install Octave Packages on Linux

    Octave /

    Octave User defined Function Example

    octave command line linux

    Octave /

    Octave Command line on Ubuntu

    Hello World in Octave

    Octave /

    Hello World in Octave

    Octave /

    Octave plot example of function y=x^2

    ‹ Install GNU Octave on Windows› Comments in Octave Scripts

    Recent Posts

    • Running Tests in Parallel with Selenium Grid
    • Advanced Selenium Features
    • Locating Web Elements
    • Running the Test Script
    • Writing Your First Selenium Test Script
    • Getting Started with Selenium Automation Testing
    • Setting Up the Environment
    • How can you monitor the Quality Assurance Audit?
    • Leveraging LambdaTest with Appium 2.0
    • Appium 2.0 Plugins ListAppium 2.0 Plugins
    • Touch Actions and Multi-Touch Actions
    • Changes in Drivers and Classes
    • Appium Inspector
    • Capabilities in Appium 2.0
    • Appium 2.0 Driver ListAppium 2.0 Driver Installation & Management
    CyberLink Multimedia Software

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com