Book Image

GNU Octave Beginner's Guide

By : Jesper Schmidt Hansen
Book Image

GNU Octave Beginner's Guide

By: Jesper Schmidt Hansen

Overview of this book

Today, scientific computing and data analysis play an integral part in most scientific disciplines ranging from mathematics and biology to imaging processing and finance. With GNU Octave you have a highly flexible tool that can solve a vast number of such different problems as complex statistical analysis and dynamical system studies.The GNU Octave Beginner's Guide gives you an introduction that enables you to solve and analyze complicated numerical problems. The book is based on numerous concrete examples and at the end of each chapter you will find exercises to test your knowledge. It's easy to learn GNU Octave, with the GNU Octave Beginner's Guide to hand.Using real-world examples the GNU Octave Beginner's Guide will take you through the most important aspects of GNU Octave. This practical guide takes you from the basics where you are introduced to the interpreter to a more advanced level where you will learn how to build your own specialized and highly optimized GNU Octave toolbox package. The book starts by introducing you to work variables like vectors and matrices, demonstrating how to perform simple arithmetic operations on these objects before explaining how to use some of the simple functionality that comes with GNU Octave, including plotting. It then goes on to show you how to write new functionality into GNU Octave and how to make a toolbox package to solve your specific problem. Finally, it demonstrates how to optimize your code and link GNU Octave with C and C++ code enabling you to solve even the most computationally demanding tasks. After reading GNU Octave Beginner's Guide you will be able to use and tailor GNU Octave to solve most numerical problems and perform complicated data analysis with ease.
Table of Contents (15 chapters)
GNU Octave
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Time for action - creating an Octave home directory under Windows


Let us assume that the Octave home directory is going to be C:\Documents and Settings\GNU Octave\. We can actually create this directory directly from Octave; so let us go ahead.

  1. 1. Start Octave and give it the following commands:

octave:1> cd C:
octave:2> cd "Documents and Settings"
octave:3> mkdir "GNU Octave"
ans = 1
  1. 2. The response ans = 1 after the last command means that the directory was successfully created. If Octave returns a zero value, then some error occurred, and Octave will also print an error message. Instead of creating the directory through Octave, you can use, for example, Windows Explorer.

  2. 3. We still need to tell the interpreter that this is now the Octave home directory. Let us do this from Octave as well:

octave:4> edit
  1. 4. You should now see an editor popping up. The default editor under Windows is Notepad++. Open the file c:\octave-home\share\octave\site\m\startup\octaverc, where octave-home is the path where Octave was installed, for example, Octave\3.2.4_gcc-4.4.0. Add the following lines at the end of the file.

    setenv('HOME', 'C:\Document and Settings\GNU Octave\');
    cd ~/
    
  2. Be sure that no typos sneaked in!

  3. 5. Save the file, exit the editor, and restart Octave. That is it.

Note

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

What just happened?

The first three Octave commands should be clear: we changed the directory to C:\Documents and Settings\ and created the directory GNU Octave. After this, we opened the global configuration file and added two commands. The next time Octave starts it will then execute these commands. The first instructed the interpreter to set the home directory to C:\Document and Settings\GNU Octave\, and the second made it enter that directory.

Creating your first .octaverc file

Having created the Octave home directory under Windows, we can customize Octave under GNU/Linux and Windows the same way.