cell array issue

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

cell array issue

schi

Hello,

running 3.2.4 on windows, I have the following issue with cell arrays:

octave.exe> string = "a b c";
octave.exe> demo2{1} = string
demo2 =

{
  [1,1] = a b c
}

octave.exe> demo2{2} = string
demo2 =

{
  [1,1] = a b c
  [1,2] = a b c
}

octave.exe> demo3{1:2} = string
error: invalid assignment to cs-list outside multiple assignment.
error: assignment to cell array failed
error: assignment failed, or no method for `<unknown type> = string'


I would like demo3 to be the same as demo2 in this case (i.e. allow for
indexing for cell arrays).

This worked as described in 3.0.3 on windows...

Any help is highly appreciated.

Thanks

Rolf
_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: cell array issue

Bård Skaflestad
On Thu, 2010-11-04 at 17:33 +0100, Schirmacher, Rolf wrote:

> Hello,
>
> running 3.2.4 on windows, I have the following issue with cell arrays:
>
> octave.exe> string = "a b c";
> octave.exe> demo2{1} = string
> demo2 =
>
> {
>   [1,1] = a b c
> }
>
> octave.exe> demo2{2} = string
> demo2 =
>
> {
>   [1,1] = a b c
>   [1,2] = a b c
> }
>
> octave.exe> demo3{1:2} = string
> error: invalid assignment to cs-list outside multiple assignment.
> error: assignment to cell array failed
> error: assignment failed, or no method for `<unknown type> = string'
>
>
> I would like demo3 to be the same as demo2 in this case (i.e. allow for
> indexing for cell arrays).
>
> This worked as described in 3.0.3 on windows...

Use either of these

        demo3(1:2)   = { string }
        [demo3{1:2}] = deal(string)

I personally prefer the first syntax, though it might not be applicable
at all times.  I'll defer to other to answer on the validity of
'demo3{1:2}=string' producing expected results in 3.0.3.


Sincerely,
--
Bård Skaflestad                            <[hidden email]>
SINTEF ICT, Applied mathematics


_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: cell array issue

John W. Eaton
Administrator
On  4-Nov-2010, Bård Skaflestad wrote:

| I'll defer to other to answer on the validity of
| 'demo3{1:2}=string' producing expected results in 3.0.3.

It was a bit of sloppiness in the interpreter that we cleaned up
because demo3{1:2} produces a comma-separated list and a
comma-separated list can't appear by itself on the left hand side of
an assignment operator.

jwe

_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave