From octave-sources-request at bevo dot che dot wisc dot edu Sun Nov 5 11:45:54 2000 Subject: Re: cell array patch From: Ariel Tankus To: Paul Kienzle CC: octave-sources at bevo dot che dot wisc dot edu Date: Sun, 5 Nov 2000 19:47:29 +0200 (GMT+0200) > > While implementing assignment, I noticed that =[] is an operator in > Matlab. That is, "x(i)=[];" deletes the ith element of x, but "y=[]; > x(i)=y;" gives a non-conformant arguments error. Hi! I was curious about this behavior of MATLAB, so I started playing with it a little. It seems to me, that their implementation is simply inconsistent, rather than there is a special operator =[]. The error message you mentioned is of unequal dimensions. Therefore, I attempted to give an equal dimension assignment: >> x = 1:5 x = 1 2 3 4 5 >> x(ones(0,0)) = ones(0,0) x = x = 1 2 3 4 5 >> x(ones(0,2)) = ones(0,0) x = 1 2 3 4 5 of course, >> ones(0,0) ans = [] It seems to me that they didn't really think of this case, and what actually happens is, that once there is a variable assignment like: x(i) = y, a dimension test is performed, and it fails on the special case where: y = []. Of course, this is just my own interpretation, and I might prove wrong, but as far as I remember MATLAB never document =[] as an operator. It appear as an operator neither in ``help ops'' nor in: ``help relop'', ``help arith'', ``help slash'' in MATLAB. I wouldn't build a whole logic on this case, because it might prove to be a bug in MATLAB, and next release might change this. Using this logic might make Octave even bug-compatible with MATLAB (which is good for compatability), but I wouldn't base more than it on the operator =[]. Anyway, I think I'll just send MATLAB a bug report on this to Mathworks, and see what is their comment. Is this OK with you, Paul? After all, you are the one who found out this operator/bug... -- Ariel. Ariel Tankus, School of Computer Science Tel-Aviv University ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------