Re: Bug in Octave 8.2.0
Nicholas Jankowski <[email protected]> Mon, 14 Aug 2023 11:05:47 -0400
| Newsgroups | gmane.comp.gnu.octave.general |
|---|---|
| Message-ID | <CALW4+bJRSK6r13UYC2M7SRM9FRG_+tukqwixuWyYONG==fZ2_Q@mail.gmail.com> |
On Mon, Aug 14, 2023 at 9:25 AM Ian McCallion <[email protected]> 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. ---------- We are transitioning to a web based forum for community help discussions at https://octave.discourse.group/c/help