[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Structure items as vectors?
From: |
Schirmacher, Rolf |
Subject: |
Structure items as vectors? |
Date: |
Mon, 14 Apr 2008 11:32:17 +0200 |
Hello,
I want to use structured information for numerical computations. I have a
structure like
octave.exe> some.data.structure(1).item = 1;
octave.exe> some.data.structure(2).item = 2;
and later on, I want to do calculations with a vector of "item"s. What I get
is a list like
octave.exe> some.data.structure.item
ans =
(,
[1] = 1
[2] = 2
,)
octave.exe> some.data.structure(:).item
ans =
(,
[1] = 1
[2] = 2
,)
On the other hand, I can access the individual elements as scalars like
octave.exe> some.data.structure(1).item
ans = 1
How can I retrive the data as a vector, i.e. overcome such errors most
easily?
octave.exe> items_doubled = 2 .* some.data.structure(:).item
error: binary operator `.*' not implemented for `scalar' by `cs-list'
operations
error: evaluating binary operator `.*' near line 59, column 19
error: evaluating assignment expression near line 59, column 15
Thanks in advance,
Rolf
- Structure items as vectors?,
Schirmacher, Rolf <=