SlideShare a Scribd company logo
http://www.tutorialspoint.com/matlab/matlab_g nu_octave.htm Copyright © tutorialspoint.com
MATLAB - GNU OCTAVE TUTOIRIAL
GNU Octave is a high-levelprogramming language like MATLAB and it is mostly compatible withMATLAB. It is
also used for numericalcomputations.
Octave has the following commonfeatures withMATLAB:
matrices are fundamentaldata type
it has built-insupport for complex numbers
it has built-inmathfunctions and libraries
it supports user-defined functions
GNU Octave is also freely redistributable software. Youmay redistribute it and/or modify it under the terms of
the GNU GeneralPublic License (GPL) as published by the Free Software Foundation.
MATLAB vs Octave
Most MATLAB programs runinOctave, but some of the Octave programs may not runinMATLAB because,
Octave allows some syntax that MATLAB does not.
For example, MATLAB supports single quotes only, but Octave supports bothsingle and double quotes for
defining strings. If youare looking for a tutorialonOctave, thenkindly go throughthis tutorialfrombeginning
whichcovers bothMATLAB as wellas Octave.
Compatible Examples
Almost allthe examples covered inthis tutorialare compatible withMATLAB as wellas Octave. Let's try
following example inMATLAB and Octave whichproduces same result without any syntax changes:
This example creates a 3D surface map for the functiong = xe-(x2 + y2). Create a script file and type the following
code:
[x,y] = meshgrid(-2:.2:2);
g = x .* exp(-x.^2 - y.^2);
surf(x, y, g)
print -deps graph.eps
Whenyourunthe file, MATLAB displays the following 3-D map:
Non-compatible Examples
Thoughallthe core functionality of MATLAB is available inOctave, there are some functionality for example,
Differential& IntegrationCalculus, whichdoes not matchexactly inboththe languages. This tutorialhas tried to
give bothtype of examples where they differed intheir syntax.
Consider following example where MATLAB and Octave make use of different functions to get the area of a
curve: f(x) = x2 cos(x) for −4 ≤ x ≤ 9. Following is MATLAB versionof the code:
f = x^2*cos(x);
ezplot(f, [-4,9])
a = int(f, -4, 9)
disp('Area: '), disp(double(a));
Whenyourunthe file, MATLAB plots the graph:
and displays the following result:
a =
8*cos(4) + 18*cos(9) + 14*sin(4) + 79*sin(9)
Area:
0.3326
But to give area of the same curve inOctave, youwillhave to make use of symbolic package as follows:
pkg load symbolic
symbols
x = sym("x");
f = inline("x^2*cos(x)");
ezplot(f, [-4,9])
print -deps graph.eps
[a, ierror, nfneval] = quad(f, -4, 9);
display('Area: '), disp(double(a));

More Related Content

PDF
PyData NYC whatsnew NumPy-SciPy 2019
PDF
Standardizing on a single N-dimensional array API for Python
PPTX
Programming Environment in Matlab
PPTX
NS3 Simulation Research Guidance
PDF
Python array API standardization - current state and benefits
PDF
NumPy Roadmap presentation at NumFOCUS Forum
PDF
Embedded Recipes 2018 - Shared memory / telemetry - Yves-Marie Morgan
PDF
Principles of programming languages(Functional programming Languages using LISP)
PyData NYC whatsnew NumPy-SciPy 2019
Standardizing on a single N-dimensional array API for Python
Programming Environment in Matlab
NS3 Simulation Research Guidance
Python array API standardization - current state and benefits
NumPy Roadmap presentation at NumFOCUS Forum
Embedded Recipes 2018 - Shared memory / telemetry - Yves-Marie Morgan
Principles of programming languages(Functional programming Languages using LISP)

What's hot (19)

PPTX
Dot net parallelism and multicore computing
PPT
Standard Template Library (STL) in Object Oriented Programming
PDF
Methods and implementation @ HAMS
PPTX
Introduction to programming in MATLAB
PPTX
Stack and queue
PPTX
Stack Data structure
PDF
The evolution of array computing in Python
PPTX
Architectural modeling
PDF
PPT
Python advanced 3.the python std lib by example –data structures
PPTX
Oops project newton second law of motion
PPTX
NumPy sorting (and dancing and memes): ​ a short review for students​
PDF
Pollyfills in JavaScript
PPT
An adaptive algorithm for detection of duplicate records
PPT
Lecture 07
PDF
(chapter 7) A Concise and Practical Introduction to Programming Algorithms in...
PPTX
Stack & heap
PPT
Python advanced 3.the python std lib by example – algorithm
Dot net parallelism and multicore computing
Standard Template Library (STL) in Object Oriented Programming
Methods and implementation @ HAMS
Introduction to programming in MATLAB
Stack and queue
Stack Data structure
The evolution of array computing in Python
Architectural modeling
Python advanced 3.the python std lib by example –data structures
Oops project newton second law of motion
NumPy sorting (and dancing and memes): ​ a short review for students​
Pollyfills in JavaScript
An adaptive algorithm for detection of duplicate records
Lecture 07
(chapter 7) A Concise and Practical Introduction to Programming Algorithms in...
Stack & heap
Python advanced 3.the python std lib by example – algorithm
Ad

Viewers also liked (18)

PDF
C24 company overview brochure lowres
PDF
Matlab calculus
PDF
C24 bi datasheet leading in the legal sector with big data
PDF
Effective resume writing
PDF
Matlab algebra
PDF
Matlab syntax
PDF
Matlab numbers
PDF
Matlab differential
PDF
Matlab plotting
PDF
Matlab operators
PDF
Matlab operators
PDF
C24 wright hassall casestudy a4 3pp
PDF
Matlab simulink
PDF
Matlab data import
PDF
Matlab integration
PDF
Matlab functions
PDF
Matlab strings
PDF
C24 Arthur Terry Case Study 365
C24 company overview brochure lowres
Matlab calculus
C24 bi datasheet leading in the legal sector with big data
Effective resume writing
Matlab algebra
Matlab syntax
Matlab numbers
Matlab differential
Matlab plotting
Matlab operators
Matlab operators
C24 wright hassall casestudy a4 3pp
Matlab simulink
Matlab data import
Matlab integration
Matlab functions
Matlab strings
C24 Arthur Terry Case Study 365
Ad

Similar to Matlab gnu octave (20)

PPTX
Matlab - Introduction and Basics
PDF
An ntutorial[1]
PDF
Introduction to MATrices LABoratory (MATLAB) as Part of Digital Signal Proces...
PPTX
Matlab Introduction
PDF
Tema2 fundamentos de matlab
PPTX
Matlab-3.pptx
PDF
Java 8-revealed
PDF
Matlab guide
PPT
Scala Talk at FOSDEM 2009
DOC
Matlab summary
DOC
Matlab tut2
PDF
EE6711 Power System Simulation Lab manual
PPT
MATLAB workshop lecture 1MATLAB work.ppt
PDF
interfacing matlab with embedded systems
DOCX
DOCX
Mmc manual
DOCX
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
PDF
The use of the code analysis library OpenC++: modifications, improvements, er...
DOCX
KEVIN MERCHANT DOCUMENT
Matlab - Introduction and Basics
An ntutorial[1]
Introduction to MATrices LABoratory (MATLAB) as Part of Digital Signal Proces...
Matlab Introduction
Tema2 fundamentos de matlab
Matlab-3.pptx
Java 8-revealed
Matlab guide
Scala Talk at FOSDEM 2009
Matlab summary
Matlab tut2
EE6711 Power System Simulation Lab manual
MATLAB workshop lecture 1MATLAB work.ppt
interfacing matlab with embedded systems
Mmc manual
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
The use of the code analysis library OpenC++: modifications, improvements, er...
KEVIN MERCHANT DOCUMENT

More from pramodkumar1804 (13)

PDF
Matlab polynomials
PDF
Matlab overview 3
PDF
Matlab overview 2
PDF
Matlab overview
PDF
Matlab variables
PDF
Matlab matrics
PDF
Matlab m files
PDF
Matlab loops 2
PDF
Matlab loops
PDF
Matlab graphics
PDF
Matlab decisions
PDF
Matlab colon notation
PDF
Matlab vectors
Matlab polynomials
Matlab overview 3
Matlab overview 2
Matlab overview
Matlab variables
Matlab matrics
Matlab m files
Matlab loops 2
Matlab loops
Matlab graphics
Matlab decisions
Matlab colon notation
Matlab vectors

Recently uploaded (20)

PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
Cell Types and Its function , kingdom of life
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
master seminar digital applications in india
PPTX
Cell Structure & Organelles in detailed.
Abdominal Access Techniques with Prof. Dr. R K Mishra
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
GDM (1) (1).pptx small presentation for students
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
RMMM.pdf make it easy to upload and study
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Supply Chain Operations Speaking Notes -ICLT Program
Microbial diseases, their pathogenesis and prophylaxis
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Cell Types and Its function , kingdom of life
Complications of Minimal Access Surgery at WLH
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
human mycosis Human fungal infections are called human mycosis..pptx
master seminar digital applications in india
Cell Structure & Organelles in detailed.

Matlab gnu octave

  • 1. http://www.tutorialspoint.com/matlab/matlab_g nu_octave.htm Copyright © tutorialspoint.com MATLAB - GNU OCTAVE TUTOIRIAL GNU Octave is a high-levelprogramming language like MATLAB and it is mostly compatible withMATLAB. It is also used for numericalcomputations. Octave has the following commonfeatures withMATLAB: matrices are fundamentaldata type it has built-insupport for complex numbers it has built-inmathfunctions and libraries it supports user-defined functions GNU Octave is also freely redistributable software. Youmay redistribute it and/or modify it under the terms of the GNU GeneralPublic License (GPL) as published by the Free Software Foundation. MATLAB vs Octave Most MATLAB programs runinOctave, but some of the Octave programs may not runinMATLAB because, Octave allows some syntax that MATLAB does not. For example, MATLAB supports single quotes only, but Octave supports bothsingle and double quotes for defining strings. If youare looking for a tutorialonOctave, thenkindly go throughthis tutorialfrombeginning whichcovers bothMATLAB as wellas Octave. Compatible Examples Almost allthe examples covered inthis tutorialare compatible withMATLAB as wellas Octave. Let's try following example inMATLAB and Octave whichproduces same result without any syntax changes: This example creates a 3D surface map for the functiong = xe-(x2 + y2). Create a script file and type the following code: [x,y] = meshgrid(-2:.2:2); g = x .* exp(-x.^2 - y.^2); surf(x, y, g) print -deps graph.eps Whenyourunthe file, MATLAB displays the following 3-D map:
  • 2. Non-compatible Examples Thoughallthe core functionality of MATLAB is available inOctave, there are some functionality for example, Differential& IntegrationCalculus, whichdoes not matchexactly inboththe languages. This tutorialhas tried to give bothtype of examples where they differed intheir syntax. Consider following example where MATLAB and Octave make use of different functions to get the area of a curve: f(x) = x2 cos(x) for −4 ≤ x ≤ 9. Following is MATLAB versionof the code: f = x^2*cos(x); ezplot(f, [-4,9]) a = int(f, -4, 9) disp('Area: '), disp(double(a)); Whenyourunthe file, MATLAB plots the graph: and displays the following result: a =
  • 3. 8*cos(4) + 18*cos(9) + 14*sin(4) + 79*sin(9) Area: 0.3326 But to give area of the same curve inOctave, youwillhave to make use of symbolic package as follows: pkg load symbolic symbols x = sym("x"); f = inline("x^2*cos(x)"); ezplot(f, [-4,9]) print -deps graph.eps [a, ierror, nfneval] = quad(f, -4, 9); display('Area: '), disp(double(a));