12.07.2015 Views

GNU Octave - Local Sector 7 web page

GNU Octave - Local Sector 7 web page

GNU Octave - Local Sector 7 web page

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6: Data Structures 476 Data Structures<strong>Octave</strong> includes support for organizing data in structures. The current implementationuses an associative array with indices limited to strings, but the syntax is more like C-stylestructures. Here are some examples of using data structures in <strong>Octave</strong>.Elements of structures can be of any value type. For example, the three expressionsx.a = 1x.b = [1, 2; 3, 4]x.c = "string"create a structure with three elements. To print the value of the structure, you can type itsname, just as for any other variable:octave:2> xx ={a = 1b =1 23 4}c = stringNote that <strong>Octave</strong> may print the elements in any order.Structures may be copied.octave:1> y = xy ={a = 1b =1 23 4}c = stringSince structures are themselves values, structure elements may reference other structures.The following statements change the value of the element b of the structure x to be a datastructure containing the single element d, which has a value of 3.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!