From bug-request at octave dot org Thu Dec 1 14:36:12 2005 Subject: double should not show usage on cell conversion From: "John W. Eaton" To: Bill Denney Cc: bug at octave dot org Date: Thu, 1 Dec 2005 15:36:06 -0500 On 16-Nov-2005, Bill Denney wrote: | When I tried to use double to convert a numeric cell array using curly | braces {} to a double array, it failed and showed the usage info for | double. I think that it should work like it does for a regular cell, or | preferably it should try to convert if it's a simple conversion of either | scalars in every cell or a row or column with equal length columns or rows | to a matrix. | | Below is the transcript of what happens. | | I know that octave-forge has cell2mat, but I just wasn't thinking of that | one at the moment when I tried this. | | Bill | | octave:1> mycells = {1 2 3 4} | mycells = | | { | [1,1] = 1 | [1,2] = 2 | [1,3] = 3 | [1,4] = 4 | } | | octave:2> class(mycells) | ans = cell | octave:3> double(mycells) | error: invalid conversion from cell to matrix | octave:3> double(mycells{:}) | | *** double: | | -- Built-in Function: double (X) | Convert X to double precision type. I don't think this is a bug. There is no conversion of cell to double (matrix), so I think the first error is correct. The second happens because mycells{:} produces a comma-separated list (i.e., an argument list with numel(mycells) distinct values) not a "double array". So double (mycells{:}) is equivalent to double (1, 2, 3, 4) which is a usage error because double expects a single argument. jwe ------------------------------------------------------------- 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 -------------------------------------------------------------