Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
GNU Octave Beginner's Guide

You're reading from   GNU Octave Beginner's Guide Become a proficient Octave user by learning this high-level scientific numerical tool from the ground up

Arrow left icon
Product type Paperback
Published in Jun 2011
Publisher Packt
ISBN-13 9781849513326
Length 280 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Jesper Schmidt Hansen Jesper Schmidt Hansen
Author Profile Icon Jesper Schmidt Hansen
Jesper Schmidt Hansen
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

GNU Octave
Credits
About the Author
About the Reviewers
1. www.PacktPub.com
2. Preface
1. Introducing GNU Octave FREE CHAPTER 2. Interacting with Octave: Variables and Operators 3. Working with Octave: Functions and Plotting 4. Rationalizing: Octave Scripts 5. Extensions: Write Your Own Octave Functions 6. Making Your Own Package: A Poisson Equation Solver 7. More Examples: Data Analysis 8. Need for Speed: Optimization and Dynamically Linked Functions Pop quiz - Answers

Structures and cell arrays


In many real life applications, we have to work with objects that are described by many different types of variables. For example, if we wish to describe the motion of a projectile, it would be useful to know its mass (a scalar), current velocity (a vector), type (a string), and so forth. In Octave, you can instantiate a single variable that contains all this information. These types of variables are named structures and cell arrays.

Structures

A structure in Octave is like a structure in C—it has a name, for example projectile, and contains a set of fields3 that each has a name, as shown in the following figure:

We can refer to the individual structure field using the.character:

structurename.fieldname

where structurename is the name of the structure variable, and fieldname is (as you may have guessed) the field's name.

3or members in C terminology

To show an example of a structure, we can use the projectile described above. Let us therefore name the structure variable...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime