help-octave
[Top][All Lists]
Advanced

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

'cat'-ing single matrices


From: Joshua Rigler
Subject: 'cat'-ing single matrices
Date: Wed, 5 Apr 2006 11:40:46 -0500
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc3 (X11/20050929)

Can someone say whether Octave versions greater than 2.1.71 have a 'cat' function that does *not* return an error if passed a single matrix? In other words, if one types:

  >> cat(1,rand(3,1))

in 2.1.71 (and earlier, I presume), an error is returned (actually, the built-in function currently forces the output of 'help cat', which is a little annoying).

It seems to me that this could be a relatively benign (non)feature where cat just returns the single variable passed to it originally. It would be helpful in the O-F contributed function cell2mat.m, which is causing me problems when I try to convert a cell array of structures to a plain old array of structures. FWIW, I did notice that cell2mat.m has been migrated from O-F to Octave since I last upgraded, but it doesn't look much different than the version of cell2mat.m I currently have.

It might also be worth noting that I tried slightly modifying cell2mat.m as follows:

  # m = cat(1, c1{:}); # changed to...
  m = cat(1, c1{:}, []);

which works fine if c1 contains a single matrix of scalars, but as you might already have surmised, when c1 contains a single array of structures, Octave-2.1.71 doesn't know what to do with the '[]', and gives the following error message:

error: concatenation operator not implemented for `struct' by `matrix' operations

Thanks for any/all advice.

-EJR



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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