[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
struct2cell creates trailing singleton dimension
From: |
David Bateman |
Subject: |
struct2cell creates trailing singleton dimension |
Date: |
Wed, 08 Apr 2009 01:38:10 +0200 |
User-agent: |
Mozilla-Thunderbird 2.0.0.17 (X11/20081018) |
The struct2cell function creates a trailing singleton dimension when the
struct array it is call with is scalar or a column vector For example
a.fld1 = 1;
a.fld2 = 2;
b = struct2cell(a);
size (b)
a(2).fld1 = 3;
a(2).fld2 = 4;
c = struct2cell(a);
size(c)
d = struct2cell(a.');
size(d)
The attached patch addresses this, though I can't easily apply the patch
at the moment, so if someone else wants to I'd appreciate it..
D.
--
David Bateman address@hidden
35 rue Gambetta +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE +33 6 72 01 06 33 (Mob)
diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-08 David Bateman <address@hidden>
+
+ * ov-cell.cc (Fstruct2cell): Treat possible trailing singleton for
+ creation of cell array from column structure vector.
+
2008-04-03 David Bateman <address@hidden>
* DLD-FUNCTIONS/max.cc (MINMAX_SPARSE_BODY): Allow sparse boolean
diff --git a/src/ov-cell.cc b/src/ov-cell.cc
--- a/src/ov-cell.cc
+++ b/src/ov-cell.cc
@@ -1357,9 +1357,13 @@
// The resulting dim_vector should have dimensions:
// [numel(fields) size(struct)]
+ // except if the struct is a column vector.
dim_vector result_dv;
- result_dv.resize (m_dv.length () + 1); // Add 1 for the fields.
+ if (m_dv (m_dv.length () - 1) == 1)
+ result_dv.resize (m_dv.length ());
+ else
+ result_dv.resize (m_dv.length () + 1); // Add 1 for the fields.
result_dv(0) = num_fields;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- struct2cell creates trailing singleton dimension,
David Bateman <=