{"id":19123955,"url":"https://github.com/cheatsheet-lang/octave","last_synced_at":"2026-03-01T06:31:44.209Z","repository":{"id":102494207,"uuid":"230249767","full_name":"Cheatsheet-lang/Octave","owner":"Cheatsheet-lang","description":"Octave Cheatsheet","archived":false,"fork":false,"pushed_at":"2020-01-10T14:03:18.000Z","size":11,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-22T13:55:09.165Z","etag":null,"topics":["conditional","function","hacktoberfest","hacktoberfest2020","matrices","octave","octave-cheatsheet","plotting","statements","syntax","vectors"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cheatsheet-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-26T11:06:48.000Z","updated_at":"2024-09-10T15:12:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"ec249cbc-531b-4745-8f3e-92354e731abc","html_url":"https://github.com/Cheatsheet-lang/Octave","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Cheatsheet-lang/Octave","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cheatsheet-lang%2FOctave","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cheatsheet-lang%2FOctave/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cheatsheet-lang%2FOctave/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cheatsheet-lang%2FOctave/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cheatsheet-lang","download_url":"https://codeload.github.com/Cheatsheet-lang/Octave/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cheatsheet-lang%2FOctave/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29962016,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T05:59:08.471Z","status":"ssl_error","status_checked_at":"2026-03-01T05:58:04.208Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conditional","function","hacktoberfest","hacktoberfest2020","matrices","octave","octave-cheatsheet","plotting","statements","syntax","vectors"],"created_at":"2024-11-09T05:27:44.943Z","updated_at":"2026-03-01T06:31:44.192Z","avatar_url":"https://github.com/Cheatsheet-lang.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Octave Cheatsheet\n\n### General Commands\n```octave\nPS1(\"custom\u003e\u003e \");        % For the Custom prompt\n\na = 3;      % The semi-colon supresses the output\n\nhelp(eye)   % Gives some description about the eye function\nwho         % Displays all the variables in the scope\nwhos        % Gives the detailed display of variables\n\nclear a     % Deletes the variable a\nclc         % Clear Screen\nclose       % Close the given figure\n\nsave variable.mat a;    % Saves the variable a in the file\nsave variable.txt a -ascii;    % Saves the variable a in human readable\n\npause;      % Go into an infinte sleep mode, by pressing enter you can return to prompt\n```\n\n## Basic Operations\n\n#### Variables\n```octave\na = 3;\nb = 'hi';\n```\n\n#### Output\n```octave\na  = pi;\na           % Simply give at the prompt\ndisp(a);    % print function in octave\ndisp(sprintf('Vaue of pi is: %0.2f', a))        % C style printing\n```\n\n#### Arthimetic Operations\n```octave\n5 + 6\n5 - 4\n5 * 8\n1 / 2\n2 ^ 6       % Exponentation\n```\n\n#### Logical Opeartions\n```octave\n1 == 2      % false\n1 ~= 2      % not equal to\n1 \u0026\u0026 0      % AND\n1 || 0      % OR\nxor(1, 0)\n```\n\n## Vectors and Matrices\n\n#### Vectors\n```octave\nrow = [1, 2, 3]     % Row vector , is a separator in a row\n\ncol = [1; 2; 3]     % Column vector ; separates the rows\n\nlength(row)         % Gives the length of vector/ length of longest dimension in matrix\n```\n\n## In-built Functions\n\n#### Mathematical\n```octave\nv = [0.26, 2.22, 4]\nmatrix = [1, 23; 30, 4; 5, 6]\n\nlog(3)              % Logrithmic\nexp([1, 2])         % Exponential\nabs([-1, 2, -3])    % Absolute\n-v                  % similar to -1 * v\n\n[val, ind] = max(v) % Returns an array of which has max value and it's index\nmax(matrix)     % Returns column-wise maximum\n\nfind([1, 0, 3, 2])      % Returns the indexes of all the non-zero elements\nmagic(3)        % returns a 3x3 magic square matrix\n\nsum(matrix)     % Sum of a matrix\nfloor(v)\nceil(v)\n```\n\n#### Matrices\n```octave\nmatrix = [1, 2; 3, 4; 5, 6]\neye(3)          % Diagonal matrix of order 3\nones(2, 3)      % [1, 1, 1; 1, 1, 1]\nzeros(1, 3)     % [0, 0, 0]\nmat = rand(3, 2)    % A random 3x2 matrix\nrandn(1, 100)   % Random matrix following a normal distribution\n\nsize(matrix)    % Gives the dimensions of the matrix as a matrix[row, column] size(\u003cmatrix\u003e, [axis])\n\nmatrix(3, 2)    % A usual matrix indexing\nmatrix(:,2)     % : means all the elements in the corrsponding row/column.\nmatrix([1 3],:) % Everything from the 1st and 3rd row\n\nmatrix = [matrix, [7; 8; 9]]   % Appending a row to the matrix(right side)\nmatrix(:, 3) = [10; 11; 12]    % Assiging a row\nmatrix(:)       % Put all the elements into a single column vector\n\nmat_concat = [matrix mat]   % Concatenate matrices side by side [matrix, mat]\nmat_concat = [matrix; mat]  % Concatenate matrices one above the other\n\nmatrix * mat    % Matrix multiplication\nmatrix .* mat   % This is element-wise multiplication, similarly .+, ./, .^\n\nmatrix'         % Matrix transpose\ntranspose(matrix)\n\npinv(matrix)    % Pseudo Inverse matrix \n```\n\n#### Iterators\n```octave\nv = 1:0.1:2     % Start:step-size:end deafult step-size is 1\n```\n\n## Plotting\n```octave\na = magic(5)\nplot(x, y)              % Makes a two dimensional graph\nhold on;                % To plot one or more plots at a time\nxlabel(\"label\")         % Label on the x-axis\nylabel(\"label\")         % Label on the y-axis\n\nprint -dpng '\u003cfilename\u003e'    % To save into a file\nsubplot(1, 2, 1)        % Divide the figure into 1 row 2 columns and access the 1st figure  \n\nimagesc(a), colorbar, colormap gray;    % Plots using colors\n\nhist(randn(1, 100))     % Plots a histogram hist(\u003cvector\u003e, [bins])\n```\n\n## Control Statements\n\n#### If else\n```octave\nv = zeros(10, 1);\n\ni = 0;\nwhile true,\n    v(i) = i*i;\n    if i == 6,\n        break;\n    else\n        disp(\"Value is not 6\")\n    end;\nend;\n```\n\n#### For\n```octave\nv = zeros(10, 1);\n\nfor i=1:10,\n    v(i) = i*i;\nend;\n```\n\n#### While\n```octave\nv = zeros(10, 1);\n\ni = 0;\nwhile i \u003c 5,\n    v(i) = 10*i;\n    i = i + 1;\nend;\n```\n\n#### Functions\n```octave\nfunction y = squareNumber(x),\n    y = x ^ 2;\nend;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheatsheet-lang%2Foctave","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheatsheet-lang%2Foctave","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheatsheet-lang%2Foctave/lists"}