|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Cell array (of structs) to array failureI may be doing this completely wrong, but it works in some cases and
used to work reliably (in 3.0.5). I've got a function returning a cell array of structs or empty elements which I'm appending to form a single array of structs. cors = [cors c{:}] This used to work, and still does most of the time. In fact, just [c{:}] is failing sometimes with the same error... error: octave_base_value::complex_array_value(): wrong type argument `struct' Any clue as to the problem, or suggestion how to do this sort of append differently (or better)? Sorry, I can't seem to duplicate the results with very simple inputs... they all seem to work. I'm attaching a saved variable "c" which fails. Here is as trimmed down a version as I can get: octave:254> c{:} ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = { maxlag = 17628 } ans = [](0x0) ans = { maxlag = 17604 } ans = { maxlag = 17612 } ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = [](0x0) ans = { maxlag = 27 } ans = { maxlag = 27 } ans = [](0x0) ans = [](0x0) octave:255> [c{:}] error: octave_base_value::complex_array_value(): wrong type argument `struct' ------------------------------------------------------------------------------ _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
Re: Cell array (of structs) to array failureI'll provide an inefficient workaround for my own problem (just so in
case no one provides better). [c{:}] fails with "error: octave_base_value::complex_array_value(): wrong type argument `struct'" So, appending the cell array onto a struct array the implicit horzcat way doesn't work. Using an explicit loop does work, but of course isn't vectorized and is only good for small arrays (really shouldn't be appending large arrays anyway). for( tmp = 1:length(c) ) if( ~isempty(c{tmp}) ) cor = [cor c{tmp}]; % append elements of c to cor endif endfor Yeah, I have a local variable named "cor"... shame on me. ------------------------------------------------------------------------------ _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
| Free embeddable forum powered by Nabble | Forum Help |