Preface


This tutorial provides an introduction to the programming packages matlab (which is a property of MathWorks©) and Octave (free of charhe). This tutorial was developed solely for the purpose of education. The tutorial accompanies the textbook Applied Differential Equations. The Primary Course by Vladimir Dobrushkin, second edition, CRC Press, 2023; https://www.routledge.com/Applied-Differential-Equations-The-Primary-Course/Dobrushkin/p/book/9781138606586. However, the tutorial contains much more details and information than the textbook permits.

If you have not taken or are not taking a course regarding matlab or programming, such as CSCI 0150 or ENGN 0030, then please start with Tutorial for the first course. For those who have used matlab before, please note that there are certain commands and sequences of input that are specific for solving differential equations, so it is best to read through this tutorial in its entirety. MathWorks updates Matlab every year. Therefore, tutorials from other sources may or may not be compatible with this tutorial.

This tutorial contains software programs that are free: you can redistribute codes and/or modify scripts under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This tutorial is distributed in the hope that its material and codes will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For full version of GNU General Public License, see https://www.gnu.org/licenses/gpl-3.0.en.html.

This tutorial corresponds to the matlab “m” files that are posted on the APMA 0340 website. You, as the user, are free to use the m files to your needs for learning how to use the matlab program, and have the right to distribute this tutorial and refer to this tutorial as long as this tutorial is accredited appropriately. Any comments and/or contributions for this tutorial are welcome; you can send your remarks to <Vladimir_Dobrushkin@brown.edu>

Return to computing page for the first course APMA0330
Return to computing page for the second course APMA0340
Return to computing page for the fourth course APMA0360
Return to Matlab tutorial for the first course APMA0330
Return to Matlab tutorial for the fourth course APMA0360
Return to the main page for the course APMA0330
Return to the main page for the course APMA0340
Return to the main page for the course APMA0360
Introduction to Linear Algebra with matlab


Matlab and Octave

Cleve Moler
matlab is a high-performance language for technical computing. It is a multi-paradigm programming language and it supports functional, imperative, procedural and object-oriented language. It was designed by Cleve Moler. Octave. is mainly used in solving the linear and nonlinear problems numerically, and for performing numerical experiments it is mostly compatible with matlab.

matlab was initially released in the year 1984; it was written in C, C++, and Java. matlab has severak ”Toolboxes” that consist of sets of functions designed for a specific purpose and compiled as a package. These Toolboxes include matlab code, apps, data, examples and the documentation which helps users to utilize each Toolbox. Users can compile matlab files to create toolboxes if they require sharing with others. There are separate Toolboxes available from Mathworks, to be used for specific purposes, for example, Simulink.

Unfortunately, Mathworks blocks a free access to information about its products and requires acceptence of cookies. In contrust, Chebfun is an open-source package for computing with functions to about 15-digit accuracy. Most Chebfun commands are overloads of familiar MATLAB commands — for example sum(f) computes an integral, roots(f) finds zeros, and u = L\f solves a differential equation.

Octave was developed by John W. Eaton. It was initially released in the year 1980, but its first official version was released on 17 February 1994. . It was written in C, C++, and Fortran.

Matlab vs Octave

Both, matlab and Octave are mainly used for the same purpose. The main difference is syntax and other features. Matlab consist of specialized toolboxes which are not part of Octave. They are not fully compatible that is code written in matlab can crush in Octave and vice versa. matlab consist of specialized toolboxes which are not part of Octave.

We list main differences in matlab and Octave:

  1. matlab consumes more RAM compared with Octave.
  2. In matlab, “! String” syntax calls a shell with command STRING. But octave does not recognize ‘!’ as the system call since it is used in logical operations.
  3. In matlab, it always requires … for line continuation. In octave, it’s not necessary to put them
  4. matlab uses ^ for exponentiation but octave can use ^ or **
  5. In matlab, the value can be assigned like a = b+1, c=a. In octave, it can be written as c=a=b+1.
  6. In matlab, we can use ‘~’, not ‘!’. In Octave, it allows users to use both ~ and ! with Boolean values.
  7. In matlab, it uses percent sign ‘%’ to begin the comment. In Octave, it uses both hash symbol # and the percent sign % interchangeably.

 

  1. Keskin, A.U., Ordinary Differential Equations for Engineers: with MATLAB Solutions, Springer; 1st ed. 2019. ISBN-13: 978-3030069995 ISBN-10: 3030069990
  2. Sullivan, E.R., Introduction to Mathematical Modeling, Difference Equations, Differential Equations, & Linear Algebra, 2018, Online.