This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Introduction Octave Code Comparisons
Introduction to GNU/Octave
A. Mani
9/1B, Jatin Bagchi RoadKolkata-700029 India
Department of Pure Mathematics, C.U.E-Mail: a.mani .cms@gmail .com
• is a software for Numeric Computations (not symbolic).• respects the four freedoms of FOSS: to use, to share, to modify andto distribute modifications. Licensed GNU GPL-2, 3
• performs best in GNU/Linux 64-bit, Free BSD.• Extensible scripting language (interpreted) with good graphicssupport.
• Octave is not Naive.
Introduction Octave Code Comparisons
Installation
• Package manager of GNU/Linux distro:Octave-audio, -image, ...• Vast collection of Contributed Packages (Tool boxes):
• > save abc Save Workspace as abc.mat• > save filename vbl .• > load filename Load vbl.• > clear var − name• Function: cast(val , type): int64, uint64,logical, char,double, doublecomplex.
• Define a Class from a Struct: class(< struct >,< name >)
Introduction Octave Code Comparisons
Functions
• use unique names for each function• function [out1,out2, ..] = name(input1, ...)
• < function body >• endfunction• script name = function name• Variable number of arguments functionval = smallest(varargin)• Unnamed arguments
Introduction Octave Code Comparisons
Scripts
• Just put the code in a file : alertscr.m• To run: > scr
• Comments: %, #
• Remember: > what
• Scripts can be ’standalone’.
Introduction Octave Code Comparisons
Solvers
• Polynomial: > c = [2,1,0,6,7,9], roots(c)• Solvers for sets of nonlinear equations• All Standard Optimization Problems• Many More ...
Introduction Octave Code Comparisons
Tool Boxes: Examples
• Fuzzy Computations:fuzzy-logic-toolkit, fl-core• Image Processing: image• Signal Processing: signal• Optimization: optim• Video Processing (via ffmpeg) :video• 3D Visualization: vrml
Introduction Octave Code Comparisons
Other Languages
• FORTRAN, C, C++, Python ... code can be used within Octave• Typically as dynamically linked libraries (shared libraries)• Easy to write C, C++ code that uses libraries of Octave likeliboctave.so
• FORTRAN-77, C: Long Robust Algorithms
Introduction Octave Code Comparisons
Code: Octave vs Matlab
• Some Octave constructs will not work in Matlab• –traditional mode more compatible• %, # for comments. C style increment decrement.• default search paths for file names - octave is better• printf - Octave, fprintf - Matlab• Whitespace [1,2] ′ , Line Breaks: rand(1... rand(1,
• 2)
Introduction Octave Code Comparisons
Code: Octave vs Matlab
• 90% Code compatibility• Many tool boxes have exact equivalents• OR contain the functionality of specific Tool Boxes.• Need a specific Tool Box?• Get it Done if you do not have the time.