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
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.