octave-maintainers
[Top][All Lists]
Advanced

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

Re: trouble with refreshdata?


From: Jaroslav Hajek
Subject: Re: trouble with refreshdata?
Date: Wed, 24 Mar 2010 07:17:45 +0100

On Tue, Mar 23, 2010 at 10:04 PM, Ben Abbott <address@hidden> wrote:
> On Tuesday, March 23, 2010, at 04:04PM, "Ben Abbott" <address@hidden> wrote:
>> On Tuesday, March 23, 2010, at 03:18PM, "John W. Eaton" <address@hidden> 
>> wrote:
>>>On 22-Mar-2010, Ben Abbott wrote:
>>>
>>>| I have a rather recent build. I tried running the refreshdata demo, but ...
>>>|
>>>| demo refreshdata
>>>| refreshdata example 1:
>>>|  x = 0:0.1:10;
>>>|  y = sin (x);
>>>|  plot (x, y, "ydatasource", "y");
>>>|  for i = 1 : 100
>>>|    pause(0.1)
>>>|    y = sin (x + 0.1 * i);
>>>|    refreshdata(gcf(), "caller");
>>>|  endfor
>>>|
>>>| refreshdata example 1: failed
>>>| cell2mat: elements must be numeric, char or logical
>>>|
>>>| Is anyone else seeing this?
>>>|
>>>| The error occurs at line 85.
>>>|
>>>|  79   for i = 1 : numel (h)
>>>|  80     obj = get (h (i));
>>>|  81     fldnames = fieldnames (obj);
>>>|  82     m = regexpi (fieldnames(obj), "^.+datasource$", "match");
>>>|  83     idx = cellfun (@(x) !isempty(x), m);
>>>|  84     if (any (idx))
>>>|  85       props = [props; {cell2mat(m(idx))}];
>>>|  86       objs  = [objs ; h(i)];
>>>|  87     endif
>>>|  88   endfor
>>>|
>>>| Ben
>>>
>>>Yes, I can duplicate this problem, but I don't knwo what the proper
>>>solution is as I don't really understand what this code is trying to
>>>do.
>>>
>>>Can you identify what changed so that this is now failing?  Unless the
>>>change was intentional, then maybe that is the real bug.
>>>
>>>jwe
>>
>>I'm also unfamiliar with this code, but I'll take a look as my time permits.
>>
>>If someone else has an idea what this code is trying to do, please let me 
>>know.
>>
>>Ben
>>
>
> Ok, I think I see what changed. The changeset below changed how cell2mat 
> behaved when the input was a cell of cells.
>
>    http://hg.savannah.gnu.org/hgweb/octave/rev/c0d0b6e37a36
>
> I made a trivial change to allow cell2mat to work for ...
>
> octave:1> cell2mat ({{1},{2},{3}})
> ans =
>
> {
>  [1,1] =  1
>  [1,2] =  2
>  [1,3] =  3
> }
>
> Is there any reason why this example should give an error?
>
> Ben
>
>

It is true that Matlab (2007) doesn't allow this, neither seems the
online docs imply so, but I really see no reason why this should not
work. Cell arrays can be used as matrices in other contexts (num2cell,
mat2cell), so I think they should work here. I apparently overlooked
that this worked before.

Matlab perhaps disallows this because it can lead to confusion whether
it's cell concatenation or whether cell2mat should recurse into the
nested arrays.

I checked in the following change that allows this case again:
http://hg.savannah.gnu.org/hgweb/octave/rev/03d0dea2309d

no need to revert the previous fix, it actually improves things.

regards

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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