From owner-bug-octave at bevo dot che dot wisc dot edu Fri Dec 1 14:55:42 1995 Subject: Mathlab-compatibility From: "John W. Eaton" To: Michael Boss Cc: bug-octave at bevo dot che dot wisc dot edu Date: Fri, 1 Dec 1995 14:55:40 -0600 Michael Boss wrote: : It seems to me that octave is incompatible with matlab in the following : way: : : In Matlab: : : x=[x 1 2 3] : : results in : : x=[1 2 3] : : In Octave: : : x=[x 1 2 3] : : results in : : x undefined I can see no good reason for allowing previously undefined variables to be ignored, even in this context. I suspect that for assignments, Matlab is first initializing the LHS of the expression to `[]' and then proceeding. For example, Matlab complains if you try x = [y, 1, 2, 3]; but not for y = []; x = [y, 1, 2, 3]; Further evidence is that Matlab also does this: >> x ??? Undefined function or variable x. but allows >> x = x to set x to an empty matrix. This looks more like a bug to me than a feature worth imitating. I think the best solution is to never reference undefined variables in your programs. A solution to your problem would be to set `empty_list_elements_ok' to "true" and then initialize x to an empty matrix before trying to use it. jwe