[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Structure to vector conversion?
From: |
John W. Eaton |
Subject: |
Structure to vector conversion? |
Date: |
Wed, 24 Sep 2008 17:00:00 -0400 |
On 24-Sep-2008, Keith White wrote:
| Is there are more efficient Octave way to perform the following
| structure to vector conversion?:
|
| for i = 1:n
| a(i) = struct(i).value;
| end
|
| I thought may be something like
| a = struct(:).value;
| but that gives an error.
Try
[struct.value]
The expression
struct.value
creates a "comma-separated list" of all the struct(i).value elements,
so [struct.value] is equivalent to
[struct(1).value, struct(2).value, ..., struct(end).value]
jwe