help-octave
[Top][All Lists]
Advanced

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

Re: Bug in Octave 8.2.0


From: Nicholas Jankowski
Subject: Re: Bug in Octave 8.2.0
Date: Mon, 14 Aug 2023 11:05:47 -0400



On Mon, Aug 14, 2023 at 9:25 AM Ian McCallion <ian.mccallion@gmail.com> wrote:
v = {};
v(1)='1'
produces:
    v =
    {
      [1,1] = 1
    }


I was surprised that this works.  In matlab this produces an error:

>> v = {}

v =

  0×0 empty cell array

>> v(1)='1'
Conversion to cell from char is not possible.


The behavior you see from Octave is what I'd expect to see from:

>> v{1}=1

v =

  1×1 cell array

    {[1]}
 
>> v = {}; v{1}=''

v =

  1×1 cell array

    {0×0 char}


Which is right. However

v = {};
v(1)=''
produces:
    error: A(I) = []: index out of bounds: value 2 out of bound 1

This is surely wrong. I should be able to initialise the cell array with empty strings???


So, the above shouldn't work because with () you're telling it to replace the cell element with RHS of your assignment, not to set the contents of the cell to the RHS of your assignment. the {} do the latter.  I would have expected Octave to error like matlab did, but perhaps this is a design choice.

 
We are transitioning to a web based forum
for community help discussions at
https://octave.discourse.group/c/help

recommend reposting this discussion over at the discourse forum linked above to get more active response from knowledgeable folks. 

reply via email to

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