[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: equivalent for C-style init: structname varname[] = {...} ?

From: Jordi Gutiérrez Hermoso
Subject: Re: equivalent for C-style init: structname varname[] = {...} ?
Date: Mon, 12 Nov 2012 15:41:12 -0500

On 12 November 2012 14:25, Yury T. <address@hidden> wrote:
> Jordi Gutiérrez Hermoso-2 wrote
>> On 12 November 2012 13:23, Yury T. &lt;
>> yury.tarasievich@
>> &gt; wrote:
>>> So, no solution is forthcoming, eh? Pity.
>> No solution to what? Have you looked at the dataframe package in OF?
>> It's more like what you would find in R.
> Well, thanks, but I was trying to move away from R and its pecularities,
> powerful as they might be.

Oh, I think R is far better suited than Octave to handle data. The
following complaints are about Matlab, but they apply to Octave too:

Dataframes are an attempt to make Octave less stupid about handling
hierarchical or categorised data.

> Solution to my little problem, of course.

I think I already gave you a solution using the struct function. But
here is another way using cell arrays:

    c = {

    { "file1.dat", par1_1, par2_1, "ID1" }, # comment
    { "file2.dat", par1_2, par2_2, "ID2" }, # comment


It won't be very easy to index per field this way, but you can try
using cell2struct to turn your cell array into a struct array. This
function basically makes on dimension of the cell array be index with

> Jordi Gutiérrez Hermoso-2 wrote
>> Also, struct arrays, cell arrays, and plain arrays are the basic types
>> in Octave. Plain arrays are of homogenous type, cell arrays are of
>> ...
>> dimension is indexed by strings instead of positive integers. These
>> are your basic building blocks, and perhaps they are enough for
>> solving your problem at hand. The cell() and struct() functions can be
>> ...
> Well, w/r to the theory of information, array is a complex data
> type, even if plain.

Complex arrays are possible, of course, but they're usually real. In
Octave "array" means "n-dimensional array" and the standard type is
"matrix", which is of homogenous type. There are no 1d arrays, btw, so
"vectors", whether plain, cell or struct arrays, are always row or
column vectors.

I'm not sure that this has anything to do with information theory,
unless you're talking about how much entropy an array type holds, or
something like this.

Keep in mind that Octave was created to do linear algebra well and is
mostly a glorified wrapper to Netlib and LAPACK. Anything else that it
can do after that is an afterthought. In particular, it grew data
structures other than matrices later, much like Matlab itself.

> That's how it's regarded in other programming languages - special
> syntax, complex indexing modes etc.

You can't index with complex numbers in Octave, only with positive
integers or you can regard struct arrays as a special kind of array
where one dimension is indexed by strings.

> BTW, even your explication on array constructors, so to speak, is
> better than what one finds in documentation. Sorry to grumble. Will
> try again. :)

I'll add something like it to the manual, then.

- Jordi G. H.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]