{"id":22874,"date":"2020-12-13T13:01:41","date_gmt":"2020-12-13T07:31:41","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/"},"modified":"2024-10-15T01:06:18","modified_gmt":"2024-10-14T19:36:18","slug":"octave-tutorial","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/","title":{"rendered":"Octave Tutorial | Everything that you need to know"},"content":{"rendered":"\n<ol class=\"wp-block-list\">\n<li><strong><a href=\"#What is Octave?\">What is Octave?<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Advantages of Octave over others\">Advantages of Octave over others<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Download Octave for your PC\">Download Octave for your PC<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Useful things to know\">Useful things to know<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Variables and Data types\">Variables and Data types<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Functions\">Functions<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Matrices\">Matrices<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Operators\">Operators<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Strings\">Strings<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Programming\">Programming<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Plotting\">Plotting<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Files I\/O\">Files I\/O<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"#Save your file &amp; load it when needed\">Save your file &amp; load it when needed<\/a><\/strong><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-octave\"><strong>What is Octave?<\/strong><\/h2>\n\n\n\n<p><strong><em>OCTAVE<\/em><\/strong> is a high\u2013level language designed for scientific computations. It is most compatible with MATLAB in speed and syntax (to some extent).<\/p>\n\n\n\n<p>Octave<strong> <\/strong>can be downloaded from <a href=\"https:\/\/www.gnu.org\/software\/octave\/download.html#ms-windows\" target=\"_blank\" rel=\"nofollow noreferrer noopener\" aria-label=\" (opens in a new tab)\">https:\/\/www.gnu.org\/software\/octave\/download.html#ms-windows<\/a>. It features a simple-to-use GUI for scripting files and a command line for instant execution of a line of code. Since it is based on MATLAB, Octave produces <em>M-files<\/em>, i.e., .<strong>m<\/strong> extension files.<\/p>\n\n\n\n<p>It is free open source software under GNU General Public License. It was made for computing linear algebra and matrices. Now, it is used for making machine learning models.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"advantages-of-octave-over-others\"><strong>Advantages of Octave over others<\/strong><\/h2>\n\n\n\n<p>There are many other languages for making machine learning models in the market, like Python, Ruby, etc. with many with built-in functions which makes them easier to use. But, one cannot understand the spices inside the functions. Using Octave, we make those spices and can manipulate it as per the requirements.<\/p>\n\n\n\n<p>There are many other advantages of using octave:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>It has C, C++ and FORTRAN as its base languages, which makes it a lot faster.<\/li>\n\n\n\n<li>Its syntax is very close to mathematical expressions which makes it a good choice for engineers.<\/li>\n\n\n\n<li>It has high level plot commands for 2D and 3D, for data visualization.<\/li>\n\n\n\n<li>It supports contour plots.<\/li>\n<\/ol>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>\u201cNow you are all set to get started.\u201d<\/em><\/strong><\/p>\n\n\n\n<p><em>In the tutorial, you will get many examples. So, it is advised to practice those by, instead of just copy-paste, typing each letter and try modifying the same. By making mistakes you will get to know many new things. Hope, you will enjoy the tutorial!<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"useful-things-to-know\"><strong>Useful Things To Know<\/strong><\/h3>\n\n\n\n<p>It is always better to know about a place before you visit. It helps you not get into trouble or helps you get out of it.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>So, in Octave, maybe the execution of your results into an infinite iteration then you can type ctrl + C to terminate the process. You can terminate any process with this shortcut.<\/li>\n\n\n\n<li>One-line commenting in Octave either using <strong># <\/strong>or<strong> %<\/strong>.<\/li>\n<\/ul>\n\n\n\n<p>&gt;&gt; % I am a one-line comment<\/p>\n\n\n\n<p>&gt;&gt;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Block commenting in Octave : <strong>#{ \u2026. #}<\/strong> or <strong>%{ \u2026 %}<\/strong>.<\/li>\n\n\n\n<li>A line of code is preferred to end with semicolon \u2018<strong>;<\/strong>\u2019 to stop the instant execution.<\/li>\n\n\n\n<li>There is one more command that will help you to understand Octave. It is about taking help from Octave by typing <em>help<\/em> or <em>doc<\/em> followed by a command about which you wanted to know. This command opens the documentation of the command in the command window or command-line interface (CLI). For instance,<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt;  help clc                             % CLC is a command in Octave\n&#039;clc&#039; is a built-in function from the file libinterp\/corefcn\/sysdep.cc\n         -- clc ()\n         -- home ()\n             Clear the terminal screen and move the cursor to the upper left corner.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t            . . .  \n\n<\/pre><\/div>\n\n\n<p>You can try these commands: <em>help help<\/em>, <em>help plot<\/em>, <em>help isvarname<\/em>, <em>help size<\/em>, <em>help inv<\/em>, <em>help pinv<\/em>, <em>help reshape<\/em>, &nbsp; &nbsp; <em>help resize<\/em>, <em>help round<\/em>, <em>help cast<\/em>, <em>help isa<\/em>, <em>help int8<\/em>, <em>help logical<\/em>,&nbsp;<\/p>\n\n\n\n<p>Octave GUI has a documentation window as well where you can find many functions and commands.<\/p>\n\n\n\n<p>To close Octave, type <em>exit<\/em> or <em>quit<\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"variables-and-datatypes\"><strong>Variables<\/strong>&nbsp;<strong>and<\/strong>&nbsp;<strong>Datatypes<\/strong><\/h2>\n\n\n\n<p><strong>Variables<\/strong> are x and y that we have been using since our junior classes. We store values in variables and the type of the value stored is called the Data<strong> type <\/strong>of the variable.<\/p>\n\n\n\n<p>Like<strong> <\/strong>other programming languages, Octave also provides a simple way to declare variables with the following conditions:<\/p>\n\n\n\n<p>1. It must be a sequence of letters, digits and underscores, not beginning from digits. So, <strong>my_var12<\/strong>, <strong>my21var_<\/strong>, <strong>_var12<\/strong> and <strong>_123var<\/strong> are valid variables but <strong>21my_var <\/strong>is an invalid variables.<strong>&nbsp;<\/strong><\/p>\n\n\n\n<p>2. It should be kept in mind that the Octave is case-sensitive. So, <strong>myVar <\/strong>and <strong>myvar<\/strong> are treated as different variables.<\/p>\n\n\n\n<p>3. To check the validity of a variable name, there is a function to use: <strong>isvarname (\u2018<\/strong>variable_name\u2019<strong>)<\/strong>. This returns Boolean value, i.e., true (<strong>1<\/strong>) or false (<strong>0<\/strong>).<\/p>\n\n\n\n<p>4. Octave has an automatic variable: <strong>ans<\/strong>,which appears on pressing \u201c<em>Enter<\/em>\u201dafter writing a line of code. <\/p>\n\n\n\n<p>Octave has some standard built-in data types for real and complex scalars, matrices, ranges, characters, a data structure type, and cell arrays. For example, \u201cscalar\u201d, \u201cmatrix\u201d, etc. The function <em>typeinfo (expr)<\/em> returns the data type of the <em>expr<\/em> in string form.<\/p>\n\n\n\n<p>As said earlier, Octave works very fast with vectors and matrices. Let\u2019s understand some small but useful terms.<\/p>\n\n\n\n<p><strong>Matrices <\/strong>are a collection of entities in some m rows and n columns. <strong>Vectors <\/strong>or<strong> arrays<\/strong> are matrices with one column or row. <strong>Scalars<\/strong> are matrices with dimension 1 x 1, i.e., a scalar is a single entity matrix. The <strong>entities<\/strong> are categorized into <strong>integers<\/strong>, <strong>characters <\/strong>and<strong> logical<\/strong>. <strong>Integers<\/strong> are set to \u201cdouble\u201d by default which has the largest range of numbers. Other values for integers are \u201cint8\u201d, \u201cint16\u201d, \u201cint32\u201d, \u201cint64\u201d, \u201cuint8\u201d, \u201cuint16\u201d, \u201cuint32\u201d, \u201cuint64\u201d and \u201csingle\u201d. <strong>Characters<\/strong> are single\/double quoted characters like \u2018ab\u2019, \u2018cdac\u2019, \u20181\u2019, etc. while <strong>logicals<\/strong> are binary values, i.e., <strong>0<\/strong> (false) and <strong>1<\/strong> (true)<\/p>\n\n\n\n<p>To create a matrix, simply type:&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3]\nA   = \n5     4    -3\n7    -6     4\n9     1     3\n&gt;&gt; \n\n<\/pre><\/div>\n\n\n<p>and Octave responses in clear matrix form.<\/p>\n\n\n\n<p>To create a vector, we just need to replace semicolon inside square braces with spaces.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; V = &#x5B;5 4 -3 7 -6 4 9 1 3]\nV   =    5     4    -3     7    -6     4     9     1     3\n\n<\/pre><\/div>\n\n\n<p>To create a character string, simply type:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; myStr = \u2018I am a string.\u2019\nmyStr = I am a string.\n\n<\/pre><\/div>\n\n\n<p>Unlike MATLAB, Octave also works the same with <strong>double<\/strong> <strong>quotes<\/strong>.<\/p>\n\n\n\n<p>To display a declared variable, just type the variable name:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; a = 23              % a is declared and the value 23 is assigned to it\na   =   23\n\n<\/pre><\/div>\n\n\n<p>To stop the instant output, semicolon \u2018<strong>;<\/strong>\u2019 is used at the end of the line:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; a;\n&gt;&gt; sin(pi);\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>But, if we don\u2019t want to display the name of the variable, then wrap the variable name in <strong>disp ()<\/strong> function.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; disp (a)      % a is declared and the value 23 is assigned to it\n  23\n\n<\/pre><\/div>\n\n\n<p>The value and data type of a variable are inconstant, i.e, it can be changed whenever required.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; myVar = 21\nmyVar   =   21\n&gt;&gt; myVar = 23\nmyVar   =   23\n&gt;&gt; disp (myVar)\n23\n\n<\/pre><\/div>\n\n\n<p>There are some tricks to know in Octave.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Command who is used to list the currently defined variables while the command whos gives more detailed list with name, size and class columns.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; who\n  A      V      a      myStr      myVar\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>We can type the previously typed code by typing the first few letters and scrolling up. It lessens our effort.<\/li>\n\n\n\n<li>Also, we can scroll up to auto write the earlier codes.<\/li>\n\n\n\n<li>There are some variables which are mathematical constants used for mathematical uses. Some of those are pi, e, realmin, realmax, eps, I, etc.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; disp (pi)                  % displays the value of pi without writing \u2018pi\u2019\n  3.1416\n&gt;&gt; disp (e)\n  2.7183\n&gt;&gt; disp (realmin)\n  2.2251e-308\n&gt;&gt; disp (realmax)\n  1.7977e+308\n&gt;&gt; disp (eps)\n  2.2204e-16\n&gt;&gt; disp(I)\n  0 + 1i  \n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"functions\"><strong>Functions<\/strong><\/h2>\n\n\n\n<p>Functions are like a device which takes some input, processes it and produces output, based on the given input.<\/p>\n\n\n\n<p>We had gone through many functions like isvariable() which takes a variable name and checks it for the validity conditions and finally returns the output. Other functions were size () returns the dimensions of the inputted matrix; strcat ()returns the inputted strings in the same order after concatenation; inv () returns the inverse of a non-singular matrix.<\/p>\n\n\n\n<p>So, there are many built-in functions in Octave to use. But, for the sake of flexibility, in Octave we can define our function as well. For this, we need to create a .m file with the function name as the filename. For instace, let we want to create sum2n () which basically takes one argument and from 1 sums to it, i.e., sum2n (3) should return 6.<\/p>\n\n\n\n<p>Lets create it in the Ocatve\u2019s editor window.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nfunction sum = sum2n (n)\n  sum = n * (n + 1) \/ 2;\nendfunction;\n\n<\/pre><\/div>\n\n\n<p>The \u2018sum\u2019 after function is a variable which will be returned when sum2n (\u2026) is executed.<\/p>\n\n\n\n<p>Let\u2019s see another example.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nfunction &#x5B;mn mx] = limits (v)\n% The function limits take a vector v and simply returns the minimum value and maximum value in the vector\n\nmn = min (v); mx = max (v);\nendfunction;\n\n<\/pre><\/div>\n\n\n<p>Now, try it in the command window as an exercise. (<strong>Hint<\/strong>: You need to assign the function to an 1x2 vector.)<\/p>\n\n\n\n<p>There is another way to create a function instantly. This function is called an anonymous <strong>function<\/strong>. Its declaration doesn\u2019t follow the systematic procedure. Also, the anonymous function can be installed into a variable. For the declaration of an anonymous function, the syntax is @ (arguments\u2026) (function\u2026).<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; @ sin (0)       % creates a sine function and instantly feed inside it 0\nans   =   0\n&gt;&gt; f = @ (x) (x*log(x +1))      % the function x*(log(x + 1)) dependent of x installed to variable \u2018f\u2019\nf   =   \n@(x) (x * log (x + 1))\n&gt;&gt; f(1)         % displays the output of function f of 1\nans   =   0.69315\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>There are many cases when we need to create a function inside a function, in that case as well we use anonymous functions.<\/p>\n\n\n\n<p>It is obvious that the variables declared inside the function are local variables and cannot be accessed from outside the function. However, local variables can be accessed outside the function using the <strong>global<\/strong> keyword.<\/p>\n\n\n\n<p>Try searching these functions: any() and all().&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"matrices\"><strong>Matrices<\/strong><\/h2>\n\n\n\n<p>The base of creating a matrix is illustrated earlier as:&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3]\nA   = \n5     4    -3\n7    -6     4\n9     1     3\n&gt;&gt; A = &#x5B;5, 4, -3; 7, -6, 4; 9, 1, 3]\nA   = \n5     4    -3\n7    -6     4\t\n9     1     3\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>As clearly visible, elements in a row are differentiated by a space or \u2018<strong>,<\/strong>\u2019.<\/p>\n\n\n\n<p>We have some special matrices in Octave. Some are zero matrix, identity matrix, and diagonal matrix.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; zeros (2, 3)          % returns a 2 by 3 matrix having all 0 elements\nans   =   \n           0     0     0\n           0     0     0\n&gt;&gt; ones (3,2)            % returns a 3 by 2 matrix having all 1 elements\nans   =   \n1\n           1     1\n           1     1\n&gt;&gt; eye (3)                 % returns an identity matrix of order 3\nans   =   \n            1     0     0\n            0     1     0\n            0     0     1\n&gt;&gt; diag (&#x5B;1 2 3])       % returns a diagonal matrix of order 3 with 1, 2, 3 as diagonal elements\nans   =   \n            1     0     0\n            0     2     0\n            0     0     3\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p><strong>Try magic (4) !<\/strong><\/p>\n\n\n\n<p>Also, we can install functions in place of numbers. For instance,&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;sin(pi)  tan(pi\/4)  cos(pi\/2); acos(-1)  atan(1)  tan(pi\/2);  cos(2*pi)  sec(2*pi)  log(23)]\nA =\n   1.2246e-16   1.0000e+00   6.1230e-17\n   3.1416e+00   7.8540e-01   1.6331e+16\n   1.0000e+00   1.0000e+00   3.1355e+00\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>Let\u2019s look at some useful matrix functions.<\/p>\n\n\n\n<p>To add a column and row to a matrix:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3]\nA   = \n5     4    -3\n7    -6     4\n9     1     3\n&gt;&gt; &#x5B;A, &#x5B;11; 22; 33]]               % Adds a column to matrix A\nans   = \n5     4    -3     11\n7    -6     4     22\n9     1     3     33\n&gt;&gt; &#x5B;A; &#x5B;11 22 33]]               % Adds a row to matrix A\nans   = \n5     4    -3\n7    -6     4\n9     1     3\n11  22   33\n &gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>Similarly, more columns and rows can be added.<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong>Remember, indexing in Octave starts from \u20181\u2019 and when extracting elements, always \u2018row comes before columns\u2019 followed by further dimensions.<\/strong><\/p>\n\n\n\n<p>To extract elements from a matrix, syntax matrix_name (index1, index2, \u2026) is used.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3]\nA   = \n5     4    -3\n7    -6     4\n9     1     3\n&gt;&gt; disp (A(1)); disp (A(2)); disp (2, 1)\n  5\n  4\n  4\n&gt;&gt; disp (A(2,3))         % display the element at 2nd row and 3rd column of matrix A\n  4 \n\n<\/pre><\/div>\n\n\n<p>From the second code in the above example, A(m, n) is <strong>the element at m<sup>th<\/sup> row and n<sup>th<\/sup> column<\/strong>.<\/p>\n\n\n\n<p>To extract all elements from a dimension, row or column, colon \u2018<strong>:<\/strong>\u2019 is used.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3]\nA   = \n5     4    -3\n7    -6     4\n9     1     3\n&gt;&gt; A(1, : )          % all elements from 1st row \nans   =    \n              5     4    -3\n&gt;&gt; A(:, 2)          % all elements from 2nd column\nans   =   \n              4\n              -6\n              1\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>We can extract a matrix (collections of rows or columns) using colon \u2018<strong>:<\/strong>\u2019 to delimit the range.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3]\nA   = \n5     4     -3\n7     -6     4\n9     1     3\n&gt;&gt; A(2:3, : )          % matrix  all elements from 2nd to 3rd rows\nans   =    \n              7     -6    4\n              9     1     3\n&gt;&gt; A(:, 1:2)         % matrix of all elements from 1st to 2nd columns\nans   =   \n             5     4\n             7    -6\n             9    1\n&gt;&gt; A(2:3, 1:2)    % matrix of all elements from 2nd to 3rd rows and 1st to 2nd columns\nans   =    \n             7    -6\n             9     1\n&gt;&gt; A(:, 2:end)    % end keyword extracts to the last index\nans   = \n            7    -6     4\n            9     1    3\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>In almost every case m:n means <strong>from m to n<\/strong>.<\/p>\n\n\n\n<p>Defining a <strong>range<\/strong> is very easy in Ocatve. It requires syntax start_num : increment(optional) : end_num.&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; range = 1:10           % an array of elements from 1 to 10 is installed in range, i.e., a row vector of 10 elements\n  range   =   \n                 1     2     3     4     5     6     7     8     9     10\n&gt;&gt; range2 = 1:2:10       \n  Range2   =   \n                    1     3     5     7     9\n&gt;&gt; \n\n<\/pre><\/div>\n\n\n<p>Another way for creating a range is linspace () command with syntax linspace (start_num, end_num, no_of_elements).&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; newRange = linspace (1: 10:10)         % creates a row vector with 10 elements starting from 1 to 10\n  newRange   =    \n                          1     2     3     4     5     6     7     8     9     10\n&gt;&gt; \n\n<\/pre><\/div>\n\n\n<p>It should be noted that the no_of_elements is not a natural number, a vector with only element 0 is produced.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; emptyV = linspace (1: 10: 0.1)\n  emptyV   =   \n                     &#x5B;] (1x0)\n&gt;&gt; emptyV2 = linspace (1: 10: 0)\n  emptyV2   =   \n                       &#x5B;] (1x0)\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>We can assign a value to an element, a row or a column using an assignment operator \u2018<strong>=<\/strong>\u2019.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3]\n  A   = \n5      4     -3\n7     -6      4\n9      1      3\n&gt;&gt; A(1, 2) = -4       % the element at 1st row and 2nd  is assigned to -4\n  A   = \n5     -4     -3\n7     -6      4\n9      1      3\n&gt;&gt; A(:, 2) = &#x5B;4; 6; -1]       % the 2nd column is assigned \n  A   = \n5     -4     -3\n7      6     4\n9     -1     3\n&gt;&gt; A(3, : ) = &#x5B;-9 1 -3]       % the 3rd row is assigned\n  A   = \n5      4     -3\n7     -6     4\n-9     1    -3\n&gt;&gt; \n\n<\/pre><\/div>\n\n\n<p>To <strong>delete<\/strong> a row or column just assign it an empty matrix <strong>[]<\/strong>.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3]\n  A   = \n5      4     -3\n7     -6      4\n9      1      3\n&gt;&gt; A(2,: ) = &#x5B;]          % the 2nd row is assigned the empty matrix and is deleted\n  A   =   \n                5     4    -3\n                 9     1     3\n&gt;&gt; newA = &#x5B;A; &#x5B;2 4 5; 3 7 1]]\n  newA   = \n  5      4    -3\n  7    -6     4\n 9      1     3\n 2     4     5\n 3     7     1\n&gt;&gt; newA(1:2:5, : ) = &#x5B;]\n  newA   = \n  7    -6     4\n  2     4     5\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>We can know about our matrix through the following commands:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3; 2 4 5; 3 7 1]\n  A   = \n  5      4    -3\n  7    -6     4\n  9      1     3\n  2     4     5\n  3     7     1\n&gt;&gt; size (A)         % returns an two element row vector having no of rows followed by no of columns\n  ans   =    \n                5     3\n&gt;&gt; no_of_rows = size (A,1)      % returns no of rows\nno_of_rows   =   5\n&gt;&gt; no_of_columns = size (A,2)      % returns no of columns\nno_of_columns   =   3\n&gt;&gt; rows (A)      % equivalent to size (A,1)\nans   =   5\n&gt;&gt; columns (A)   % equivalent to size (A,2)\nans   =   3\n&gt;&gt; &#x5B;m n] = size (A)       % m =&gt; no of rows &amp;amp; n =&gt; no of columns (good practice)\nm   =   5\nn   =   3\n&gt;&gt; length (A)         % returns the max of size (A)\nans   =   5\n&gt;&gt; numel (A)         % returns the total no of elements in A\nans   =   15\n&gt;&gt; isempty (A)      % returns logical if A is empty(1) or not (0)\nans   =   0\n&gt;&gt; ismatrix (A)     % checks for matrix, similar is isvector()\nans   =   1\n&gt;&gt; \n\n<\/pre><\/div>\n\n\n<p>Now, let\u2019s look into some of the matrix operations:<\/p>\n\n\n\n<p><strong>Transpose of a matrix<\/strong> is a matrix produced by interchanging rows and columns. In Octave, <strong>the transpose<\/strong> <strong>of A<\/strong> is A\u2019.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3; 2 4 5; 3 7 1]\n  A   = \n  5      4    -3\n  7    -6     4\n  9      1     3\n  2     4     5\n  3     7     1\n&gt;&gt; A\u2019          % also transpose (A)\nans   =   \n                5   7   9   2   3\n                4  -6   1   4   7\n               -3   4   3   5   1\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p><strong>Determinant <\/strong>(|A|) is a unique number associated with a square matrix (matrix with equal no of rows and columns). We calculate it using <strong>det()<\/strong> function.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3];\n&gt;&gt; det (A)         % returns the determinant of A\nans   =   -233\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p><strong>Inverse of a matrix A <\/strong>(A<sup>-1<\/sup>) is a matrix such that the matrix multiplication of A and its inverse results into an identity matrix <strong>I<\/strong>, i.e., <strong>A*A<sup>-1<\/sup> = I<\/strong>. For a matrix to be invertible, it must be <strong>singular<\/strong>, i.e, |A| \u2260 0. In Octave, <strong>inverse of A<\/strong> is inv (A).<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; A = &#x5B;5 4 -3; 7 -6 4; 9 1 3]\nA   =   \n           5     4    -3\n           7    -6     4\n           9     1     3\n&gt;&gt; inv (A)        % returns the inverse of A\nans =\n           0.0944206   0.0643777   0.0085837\n          -0.0643777  -0.1802575   0.1759657\n          -0.2618026  -0.1330472   0.2489270\n&gt;&gt;    \n\n<\/pre><\/div>\n\n\n<p>However, for <strong>non-singular square matrices<\/strong>, there is a <strong>pseudo-inverse<\/strong> function pinv () to calculate the inverse.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"operators\"><strong>Operators<\/strong><\/h2>\n\n\n\n<p>Like other programming languages, octave also has operators. Let\u2019s see some of them.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Arithmetic Operators<\/strong><\/li>\n<\/ul>\n\n\n\n<p>These operators are used for simple mathematical operations.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Arithmetic Operators<\/strong><\/td><\/tr><tr><td><strong>+<\/strong><\/td><td>It is <strong>unary operator<\/strong> and <strong>binary operator<\/strong> for normal additions.<\/td><\/tr><tr><td><strong>-<\/strong><\/td><td>It is also unary as well as binary operators.<\/td><\/tr><tr><td>*<\/td><td>It is scalar and matrix<strong> multiplication operator<\/strong>. For instance, two matrices A and B the matrix product is written as <strong>A*B<\/strong>.<\/td><\/tr><tr><td>\/<\/td><td>It is a right-division operator. For two matrices A and B, <strong>A\/B<\/strong> is conceptually equivalent to A*inv (A).&nbsp;<\/td><\/tr><tr><td>\\<\/td><td>It is a left-division operator. For two matrices A and B, <strong>A\\B<\/strong> is conceptually equivalent to inv (A)*B.<\/td><\/tr><tr><td>^ <strong>or <\/strong>**<\/td><td>It is an exponentiation operator. For a matrix A, <strong>A^n<\/strong> is equivalent to A*A*A*\u2026\u2026 n times<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Octave supports <strong>\u2018.\u2019<\/strong> operator for <strong>element-wise operations<\/strong> in case of matrices.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>.*<\/td><td>It is an element-wise multiplication operator.<\/td><\/tr><tr><td>.\/<\/td><td>It is an element-wise right-division operator.<\/td><\/tr><tr><td>.\\<\/td><td>It is an element-wise left-division operator.<\/td><\/tr><tr><td>.^ <strong>or <\/strong>.**<\/td><td>It is an element-wise exponentiation operator.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>For instance, consider a matrix <strong>A = [1&nbsp; 2&nbsp; 3; 4&nbsp; 5&nbsp; 6; 7&nbsp; 8&nbsp; 9]<\/strong><\/p>\n\n\n\n<p>In Octave, matrix multiplication \ud83e\udc6a <strong>A^2 = [30&nbsp; 36&nbsp; 42;&nbsp; 66&nbsp; 81&nbsp; 96;&nbsp; 102&nbsp; 126&nbsp; 150]<\/strong><\/p>\n\n\n\n<p>And, element-wise multiplication \ud83e\udc6a <strong>A.^2 = [1&nbsp; 4&nbsp; 9;&nbsp; 16&nbsp; 25&nbsp; 36;&nbsp; 49&nbsp; 64&nbsp; 81]<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Relational Operators<\/strong><\/li>\n<\/ul>\n\n\n\n<p>These are binary operators and returns only <strong>0<\/strong> and <strong>1<\/strong> if the result of the operation is false and true respectively.<\/p>\n\n\n\n<p>These operators work on both scalar and non-scalar entities. With arrays, it performs element-wise operations.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Relational Operators<\/strong><\/td><\/tr><tr><td>==<\/td><td>It is an <strong>equal<\/strong> <strong>to<\/strong> operator.<\/td><\/tr><tr><td>~=<\/td><td>It is a <strong>not<\/strong> <strong>equal<\/strong> <strong>to<\/strong> operator.<\/td><\/tr><tr><td>&lt;<\/td><td>It a <strong>less<\/strong> <strong>than<\/strong> operator.<\/td><\/tr><tr><td>&lt;=&nbsp;<\/td><td>It is a <strong>less<\/strong> <strong>than<\/strong> or <strong>equal<\/strong> <strong>to<\/strong> operator.<\/td><\/tr><tr><td>&gt;<\/td><td>It is a <strong>greater<\/strong> <strong>than<\/strong> operator.<\/td><\/tr><tr><td>&gt;=<\/td><td>It is a <strong>greater<\/strong> <strong>than<\/strong> or <strong>equal<\/strong> <strong>to<\/strong> operator.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Logical Operators<\/strong><\/li>\n<\/ul>\n\n\n\n<p>These operators take <strong>0<\/strong>s and <strong>1<\/strong>s as<strong> <\/strong>arguments and return the binary numbers. Its syntax is :<\/p>\n\n\n\n<p><em>(expr1) logical_operator (expr2)<\/em><\/p>\n\n\n\n<p>For non-scalar exprs\u2019, logical operators returns an of binary numbers.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Logical<\/strong> <strong>Operators<\/strong><\/td><\/tr><tr><td>|<\/td><td>It is an <strong>OR <\/strong>operator. It returns <strong>1<\/strong> if any of <em>expr1<\/em> or <em>expr2<\/em> is true else returns <strong>0<\/strong>.<\/td><\/tr><tr><td>&amp;<\/td><td>It is an <strong>AND<\/strong> operator. It returns <strong>1<\/strong> only if both <em>expr1<\/em> and <em>expr2<\/em> are true else returns <strong>0<\/strong>.<\/td><\/tr><tr><td>!<\/td><td>It is a <strong>NEGATION <\/strong>operator. Its syntax is <strong>! (expr).<\/strong> It returns <strong>1<\/strong> only if expr is false else returns <strong>0<\/strong>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Instead of logical operators, there are three functions or (x1, x2, \u2026), and (x1, x2, \u2026), and not (x1).<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Other Operators<\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Other Operators<\/strong><\/td><\/tr><tr><td>++<\/td><td>It is an increment operator. It increases the value by unity.<\/td><\/tr><tr><td>--<\/td><td>It is a decrement operator. It decreases the value by unity.<\/td><\/tr><tr><td>+=<\/td><td>It is a <strong>plus-equal<\/strong> <strong>to<\/strong> operator. <strong>a += 2<\/strong> is equivalent to <strong>a = a + 2<\/strong>.<\/td><\/tr><tr><td>-=<\/td><td>It is a <strong>minus-equal<\/strong> <strong>to<\/strong> operator. <strong>a -= 2<\/strong> is equivalent to <strong>a = a - 2<\/strong>.<\/td><\/tr><tr><td>*=<\/td><td>It is a <strong>multiplication-equal<\/strong> <strong>to<\/strong> operator. <strong>a *= 2<\/strong> is equivalent to <strong>a = a * 2<\/strong>.<\/td><\/tr><tr><td>\/=<\/td><td>It is a <strong>division-equal<\/strong> <strong>to<\/strong> operator. <strong>a \/= 2<\/strong> is equivalent to <strong>a = a \/ 2<\/strong>.<\/td><\/tr><tr><td>^=<\/td><td>It is a <strong>exponentiation-equal<\/strong> <strong>to<\/strong> operator. <strong>a ^= 2<\/strong> is equivalent to <strong>a = a ^ 2<\/strong>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"strings\"><strong>Strings<\/strong><\/h2>\n\n\n\n<p>In Octave, a string is treated as an array of characters. For instance,<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; myStr = \u2018I am a string.\u2019\nmyStr   =   I am a string\n&gt;&gt; whos\n            Attr  Name        Size                       Bytes  Class\n            ==== ====        ====                     =====  =====\n                      m              1x14                           14  char\n&gt;&gt; % Some string operations\n&gt;&gt; myStr (4)          % returns the character at index 4\nans   =   m\n&gt;&gt; myStr (3:10)     % returns the characters from index 3 to 10 in a sequence\nans   =   am a str\n&gt;&gt; myStr (1: 2: 12)     % returns the characters from index 1 to 12 stepping to second character after each character\nans   =    Ia  ti\n&gt;&gt; c = 21; int2str (c)             % the function converts integer (21) to string\nans   =   21\n&gt;&gt; d = 23.98674; num2int (d)   % the function converts the number to string\nans   =   23.98674\n&gt;&gt; num2int (d, 5)           % the function converts the number to string and prints first 5 characters\nans   =   23.986\n&gt;&gt; strcat (mystr(1: 7), \u2018concatenated\u2019, mystr(7:end))\nans   =   I am a concatenated string\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>There are more functions that you can search in Octave using the help command. Try searching these functions:<\/p>\n\n\n\n<p>strjust(), str2num(), tolower(), toupper().&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"programming\"><strong>Programming<\/strong><\/h2>\n\n\n\n<p>So far, we have been seeing Octave as a calculator. Now, we will try to use it as a programming language using some decision making statements, for and while loops, etc.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"decision-making-statements\"><strong>Decision-Making Statements<\/strong><\/h4>\n\n\n\n<p><strong>If statement<\/strong> executes the code inside it if the condition given to it is true.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; age = 14;\n&gt;&gt; if  (age &amp;lt; 16),\n    disp(\u2018You are below 16 yrs.\u2019);\n    endif;\nYou are below 16 yrs.\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p><strong>If-elseif statement<\/strong> executes the code instantly if the condition above it is true.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; age = 14;\n&gt;&gt; if (age &amp;lt; 12),\n    disp(\u2018You are under 12\u2019);\n    elseif (age &amp;lt; 18),\n    disp(\u2018You are a teen.\u2019);\n    else \n    disp(\u2018You are above 18.\u2019)\n\t\t end\nYou are a teen.\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p><strong><sup>*<\/sup><\/strong>There is no limit in using <strong>elseif<\/strong> conditions.<\/p>\n\n\n\n<p><strong>Switch statement<\/strong> is case-specific, i.e., only that line of code will be executed whose case label satisfies the switch condition.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; age = 12;\n&gt;&gt; switch (age),       % age is set to 12\n    case 5\n         disp(\u2018You are 5 yrs old.\u2019);\n    case 12\n         disp(\u2018You are 12 yrs old.\u2019);\n    case 18\n         disp(\u2018You are 18 yrs old.\u2019)\n\t otherwise\n         disp(\u2018You are an adult.\u2019)\n    end\nYou are 12 yrs old.\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"iterative-loops\"><strong>Iterative Loops<\/strong><\/h4>\n\n\n\n<p><strong>do-until<\/strong> loop iterates until the until condition not fulfilled. Its syntax is do,&nbsp; body; until (condition) which seems really easy to understand like \u2018<em>iterate the body till the until condition is not reached\u2019<\/em>. In the below example, we will create the loop to get the factorial of a number.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; fact = 1; i = 1;       % variables fact and i is initialized to 1\n&gt;&gt; do        % initializes the do-until loop\n  i++;         % increases the variable I by unity until it fulfills the until condition\n  fact *= i;      % similar to fact = fact * i ; excutes until i fulfills the until condition\n  until (i == 5)     % ends the do-until loop after declaring the until condition.\n&gt;&gt; fact        % installs the current value of \u2018fact\u2019 to the Octave variable ans\nans   =   120\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p><strong>while statement <\/strong>iterates till the conditions holds true. For example,<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; i = 0;       % variable i is initialized to 0\n&gt;&gt; while i&amp;lt;10,       % initializes the while loop by declaring while-condition\n    i++;         % increments i each time till it fulfils the while-condition\n    i         % prints the value in i\n    endwhile\ni   =   1\ni   =   2\ni   =   3\ni   =   4\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p><strong>for statement <\/strong>iterates the code untill the expression completes. For example,<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; for i = 1:10,      % initializes the for loop and the variable i, feed it value from 1 to 10 in each iteration\n    i            % prints  i in each iteration\n    endfor\ni   =   2\ni   =   3\ni   =   4\ni   =   5\ni   =   6\ni   =   7\ni   =   8\ni   =   9\ni   =   10\ni   =   11\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>To interrupt a loop, break keyword to get out of the loop (for or while) while to skip the rest of the body continue keyword is used.<\/p>\n\n\n\n<p>In speed, the for and while loops are almost the same. So, use that one which is easier to use.<\/p>\n\n\n\n<p>To know the time taken by Octave to execute the whole loop, use <strong>tic<\/strong>-<strong>tac<\/strong> command. Write <strong>tic<\/strong> above and <strong>tac<\/strong> below the loop. For instance,<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; i = 0;       % variable i is initialized to 0\n&gt;&gt; tic, while i&amp;lt;10,       % tic initializes the time to 0 seconds\n    i++;         % increments i each time till it fulfils the while-condition\n    i         % prints the value in i\n    endwhile, toc       % toc returns the time taken to execute the while loop from time = 0 seconds\nElapsed time is 1.7881e-05 seconds.\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>Note, the time shown to me may vary to you for the same code. It time it outputs is based on your system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"plotting\"><strong>Plotting<\/strong><\/h2>\n\n\n\n<p>Octave provides an interactive graph. This graph is invoked using plot() function which requires two arrays as arguments. For instance,<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; x = -10:0.1:10;\n&gt;&gt; plot(x, sin (x))        % plots the \u2018x\u2019 in x-axis and sin of x in y-axis\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>Some useful commands in Octave for plottings:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>clear all<\/td><td>It clears all opened figures.<\/td><\/tr><tr><td>grid on<\/td><td>It shows grid on the plot.<\/td><\/tr><tr><td>grid off<\/td><td>It shows no grid on the plot. It is the default situation.<\/td><\/tr><tr><td>axis ([\u2026])<\/td><td>It delimits the axes. It takes a vector containing 4 elements, first two are the range of x-axis and the other two are the range of y-axis.<\/td><\/tr><tr><td>title (\u2018\u2026\u2019)<\/td><td>It sets the title of the plot.<\/td><\/tr><tr><td>xlabel (\u2018\u2026\u2019)<\/td><td>It sets the x-label, i.e., the name of x-axis on the plot.<\/td><\/tr><tr><td>ylabel (\u2018\u2026\u2019)<\/td><td>It sets the y-label, i.e., the name of y-axis on the plot.<\/td><\/tr><tr><td>legend (\u2018\u2026\u2019)<\/td><td>The <strong>legend<\/strong> is the name the line\/curve in the graph. The function sets it and displays it on the plot. We can decide the position of legend by giving attribute \u2018location\u2019 to <strong>legend (\u201clocation\u201d, \u2018north\u2019)<\/strong>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Let\u2019s use the above commands to plot a meaningful sin function.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; x = -10:0.1:10;    % creates a vector with numbers from -10 to 10 with difference 0.1\n&gt;&gt; y = sin (x);         % creates a vector containing the sin of each number in \u2018x\u2019\n&gt;&gt; plot (x, y);         % creates a figure showing the x-y graph and displays the below image\n&gt;&gt; grid on;           % shows the plot on grid\n&gt;&gt; axis (&#x5B; -10 10 -1 1]);       % delimits the axes\n&gt;&gt;  title (\u2018sin function\u2019);     %sets title to the graph\n&gt;&gt; xlabel (\u2018x\u2019);        % sets x-label to \u2018x\u2019\n&gt;&gt; ylabel (\u2018sin (x)\u2019);       % sets y-label to \u2018sin (x)\u2019\n&gt;&gt; legend (\u2018sin\u2019);         % sets legend to \u2018sin\u2019\n&gt;&gt; legend (\u2018location\u2019, \u2018north\u2019);         % locates the legend at center and top\n&gt;&gt; \n\n<\/pre><\/div>\n\n\n<p>We can make this plot more beautiful by adding some color or by increasing the line-width. For more clarity, type the command help plot.<\/p>\n\n\n\n<p>We can use fplot () for making graph of functions. Using fplot () is a faster way of plotting which takes the function and the limits (in a vector form) as arguments.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; fplot (@sin, &#x5B;-10 10]);        % creates the graph of sin function from -10 to 10\n &gt;&gt; grid on;           % shows the plot on grid\n&gt;&gt; title (\u2018sin function\u2019);     %sets title to the graph\n&gt;&gt; xlabel (\u2018x\u2019);        % sets x-label to \u2018x\u2019\n&gt;&gt; ylabel (\u2018sin (x)\u2019);       % sets y-label to \u2018sin (x)\u2019\n&gt;&gt; legend (\u2018sin\u2019);         % sets legend to \u2018sin\u2019\n&gt;&gt; legend (\u2018location\u2019, \u2018north\u2019);         % locates the legend at center and top\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>We can load a figure to a variable, say h, just by assigning it to <strong>h<\/strong>. The <strong>h<\/strong> is called graphics handle. It is a pointer to denote a figure by assigning each figure a unique number. For instance,<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; gh = figure ();      % creates a graphics handle \u2018gh\u2019\n&gt;&gt; fplot (@sin, &#x5B;-3 3])\n&gt;&gt; gh        % prints the value inside the graphics handle \u2018gh\u2019\nans   =   1\n&gt;&gt; get (h, \u2018type\u2019)        % get () function prints property, here \u2018type\u2019, of the handle given to it\nans   =   figure\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>Let\u2019s see some manipulative commands.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>hold on<\/td><td>It holds the current plot and let the next plot (s) to superimpose on it.<\/td><\/tr><tr><td>hold off<\/td><td>It releases the plot from the <strong>hold<\/strong> state.<\/td><\/tr><tr><td>subplot ()<\/td><td>It shows two or more plots in one figure. The plots order are managed in a matrix form.<em>This will be illustrated later<\/em>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Time to apply!<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; fplot(@sin, &#x5B;-5 5]);\n&gt;&gt; xlabel (\u2018x\u2019); ylabel (\u2018f (x)\u2019);\n&gt;&gt; hold on;        % holds the plot for addition of the following plot \n&gt;&gt; fplot (@cos, &#x5B;-5 5]);\n&gt;&gt; legend (\u2018sin\u2019, \u2018cos\u2019);      % sets legend to the plots in order\n&gt;&gt; title (\u2018sine-cosine waves on the same plot\u2019);\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>Look at the subplot () function.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; subplot (2, 1, 1)       % creates a figure having two subplots in 2 x 1 matrix form, the third argument is the index of the subplot\n&gt;&gt; fplot (@sin, &#x5B;-5 5]) ;        % plots the graph on the first subplot\n&gt;&gt; xlabel (\u2018x\u2019); ylabel (\u2018sin (x)\u2019)      % sets x-y labels\n&gt;&gt; legend (\u2018sin\u2019, \u2018location\u2019, \u2018northwest\u2019);      % sets legend to \u2018sin\u2019 and locates it at top and left of the subplot\n&gt;&gt; title (\u2018sine wave\u2019);        % sets title to \u2018sine wave\u2019\n&gt;&gt; subplot (2, 1, 2)         % creates the second subplots\n&gt;&gt; fplot (@cos, &#x5B;-5 5]);       % plots the graph on the second subplot\n&gt;&gt; xplot (\u2018x\u2019); ylabel (\u2018cos (x)\u2019)      % sets x-y label\n&gt;&gt; legend (\u2018cos\u2019, \u2018location\u2019, \u2018northwest\u2019)        % sets legend to \u2018cos\u2019 and locates it at top and left of the subplot\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>Now, we have made many figures. It's time to save it. Octave provides some formats to save the graphics.<\/p>\n\n\n\n<p>Some useful formats are jpg, jpeg, png for images and others are pdf, however the default ps format. Its syntax is saveas (graphics_handle, \u2018file_name\u2019, \u2018options\u2019). We can set format inside options. For instance,<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; gh = figure ();       % creates a graphics handle\n&gt;&gt; fplot (@sin, &#x5B;-3 3]);        % plot sine function\n&gt;&gt; xlabel (\u2018x\u2019); ylabel (\u2018sin (x)\u2019);        % sets x-y labels\n&gt;&gt; title (\u2018Sine Wave\u2019);          % sets title\n&gt;&gt; saveas (gh, \u2018sine wave\u2019, \u2018jpg\u2019);        % save the figure in the current directory with name \u2018sine wave\u2019 in \u2018jpg\u2019 format\n&gt;&gt;\n\n<\/pre><\/div>\n\n\n<p>You should see the following <strong>jpg<\/strong> image in the directory.<\/p>\n\n\n\n<p>Try other formats that suit you.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"files-i-o\"><strong>Files I\/O<\/strong><\/h2>\n\n\n\n<p>Now, we will see some useful system commands on Octave. These commands are inherited from UNIX.<\/p>\n\n\n\n<p>Let\u2019s see some of them.<br><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>cd \u2018path\u2019<\/td><td>It stands for <strong>change<\/strong> <strong>directory<\/strong>. It changes the directory to the <strong>path<\/strong> given to it.<\/td><\/tr><tr><td>chdir \u2018newdir\u2019<\/td><td>It changes directory to <strong>newdir<\/strong><\/td><\/tr><tr><td>mkdir \u2018newdir\u2019<\/td><td>It creates directory and names it <strong>newdir<\/strong>.<\/td><\/tr><tr><td>diary<\/td><td>It records the commands executed and the output they produce. It wakes up when switching it to <strong>on <\/strong>(<em>&gt;&gt; diary on<\/em>)&nbsp; and sleeps when switch it to <strong>off <\/strong>(<em>&gt;&gt; diary off<\/em>) while when no arguments is given sustains the current state.<\/td><\/tr><tr><td>Date<\/td><td>It is used to display the present date.<\/td><\/tr><tr><td>delete<\/td><td>It is used to delete a file.<\/td><\/tr><tr><td>dir<\/td><td>It is used to list all the files in the present directory.<\/td><\/tr><tr><td>pwd<\/td><td>It stands for present working directory. It is used to display the current directory.<\/td><\/tr><tr><td>type<\/td><td>It is used to display contents of a file.<\/td><\/tr><tr><td>what<\/td><td>It is used to list all .m files, i.e., Octave and MATLAB files.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Practice it. This increases your interaction with the system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"save-your-file-load-it-when-needed\"><strong>Save your file &amp; Load it when needed<\/strong><\/h2>\n\n\n\n<p>Octave CLI (command line interface) saves our file in our desired path using <strong>save \u2026 <\/strong>command. For instance,<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; save myfile              % saves myfile to the current directory\n&gt;&gt; save desiredPath\\myOctaveFiles\\myfile1\t  % saves myfile1 to the myOctaveFiles\n\n<\/pre><\/div>\n\n\n<p>Files are loaded also in Octave CLI using <strong>load \u2026. <\/strong>command. For instance,<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&gt;&gt; load myfile              % loads myfile\n&gt;&gt; load desiredPath\\myOctaveFiles\\myfile1\t  % loads myfile1 \n\n<\/pre><\/div>\n\n\n<p>using load command we can also load data&nbsp; in <strong>.txt<\/strong> format.<\/p>\n\n\n\n<p>This brings us to the end of the blog on Octave Tutorial. We hope that you found this helpful and were able to learn more about the concepts. If you wish to learn more such skills, join <a href=\"https:\/\/www.mygreatlearning.com\/academy\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Great Learning Academy's pool of Free Online Courses (opens in a new tab)\">Great Learning Academy's pool of Free Online Courses<\/a>! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Octave? OCTAVE is a high\u2013level language designed for scientific computations. It is most compatible with MATLAB in speed and syntax (to some extent). Octave can be downloaded from https:\/\/www.gnu.org\/software\/octave\/download.html#ms-windows. It features a simple-to-use GUI for scripting files and a command line for instant execution of a line of code. Since it is based [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":22934,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[],"content_type":[],"class_list":["post-22874","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>What is an Octave in Music | Octave Tutorial<\/title>\n<meta name=\"description\" content=\"OCTAVE Tutorial is a high\u2013level language designed for scientific computations. It is most compatible with MATLAB in speed and syntax (to some extent).\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Octave Tutorial | Everything that you need to know\" \/>\n<meta property=\"og:description\" content=\"OCTAVE Tutorial is a high\u2013level language designed for scientific computations. It is most compatible with MATLAB in speed and syntax (to some extent).\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-13T07:31:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-14T19:36:18+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1254\" \/>\n\t<meta property=\"og:image:height\" content=\"836\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"24 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Octave Tutorial | Everything that you need to know\",\"datePublished\":\"2020-12-13T07:31:41+00:00\",\"dateModified\":\"2024-10-14T19:36:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/\"},\"wordCount\":3172,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/iStock-1125274914.jpg\",\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/\",\"name\":\"What is an Octave in Music | Octave Tutorial\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/iStock-1125274914.jpg\",\"datePublished\":\"2020-12-13T07:31:41+00:00\",\"dateModified\":\"2024-10-14T19:36:18+00:00\",\"description\":\"OCTAVE Tutorial is a high\u2013level language designed for scientific computations. It is most compatible with MATLAB in speed and syntax (to some extent).\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/iStock-1125274914.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/iStock-1125274914.jpg\",\"width\":1254,\"height\":836,\"caption\":\"octave tutorial\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/octave-tutorial\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AI and Machine Learning\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/artificial-intelligence\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Octave Tutorial | Everything that you need to know\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"What is an Octave in Music | Octave Tutorial","description":"OCTAVE Tutorial is a high\u2013level language designed for scientific computations. It is most compatible with MATLAB in speed and syntax (to some extent).","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Octave Tutorial | Everything that you need to know","og_description":"OCTAVE Tutorial is a high\u2013level language designed for scientific computations. It is most compatible with MATLAB in speed and syntax (to some extent).","og_url":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2020-12-13T07:31:41+00:00","article_modified_time":"2024-10-14T19:36:18+00:00","og_image":[{"width":1254,"height":836,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"24 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Octave Tutorial | Everything that you need to know","datePublished":"2020-12-13T07:31:41+00:00","dateModified":"2024-10-14T19:36:18+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/"},"wordCount":3172,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg","articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/","url":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/","name":"What is an Octave in Music | Octave Tutorial","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg","datePublished":"2020-12-13T07:31:41+00:00","dateModified":"2024-10-14T19:36:18+00:00","description":"OCTAVE Tutorial is a high\u2013level language designed for scientific computations. It is most compatible with MATLAB in speed and syntax (to some extent).","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg","width":1254,"height":836,"caption":"octave tutorial"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/octave-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"AI and Machine Learning","item":"https:\/\/www.mygreatlearning.com\/blog\/artificial-intelligence\/"},{"@type":"ListItem","position":3,"name":"Octave Tutorial | Everything that you need to know"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg",1254,836,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914-300x200.jpg",300,200,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914-768x512.jpg",768,512,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914-1024x683.jpg",1024,683,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg",1254,836,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg",1254,836,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg",640,427,false],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg",96,64,false],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/11\/iStock-1125274914.jpg",150,100,false]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"What is Octave? OCTAVE is a high\u2013level language designed for scientific computations. It is most compatible with MATLAB in speed and syntax (to some extent). Octave can be downloaded from https:\/\/www.gnu.org\/software\/octave\/download.html#ms-windows. It features a simple-to-use GUI for scripting files and a command line for instant execution of a line of code. Since it is based&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/22874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=22874"}],"version-history":[{"count":78,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/22874\/revisions"}],"predecessor-version":[{"id":85783,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/22874\/revisions\/85783"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/22934"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=22874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=22874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=22874"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=22874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}