From: Eric Durant Subject: Bug in "for": complex not stripped from index type Date: 26 Mar 2000 00:00:00 GMT Message-ID: <38DE9776.E7874A3E@engin.umich.edu> Content-Transfer-Encoding: 7bit X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@eecs.umich.edu X-Trace: news.eecs.umich.edu 954111964 36218 141.213.6.39 (26 Mar 2000 23:06:04 GMT) Organization: EECS Dept. Univ. of Michigan Mime-Version: 1.0 Newsgroups: comp.soft-sys.matlab There seems to be a bug in `for` in Matlab when the index variable contains a complex value prior to the loop. The following code demonstrates this behavior: ================= j = sqrt(-1); for j = 1:3, j end ================= The third line causes the values 1 + 1i, 2 + 1i and 3 + 1i to be output instead of the expected values 1, 2 and 3. This is inconsistent with the Matlab documentation, which states that the values in the expression to the right of the `=` are stored in the loop variable (no mention is made of handling overwriting a complex double with a non-complex double as a special case). I've observed this behavior in the following versions of Matlab: MATLAB Version 5.3.1.29215a (R11.1) on PCWIN MATLAB Version 5.3.1.29215a (R11.1) on HP700 MATLAB Version 5.3.1.29215a (R11.1) on SOL2 I'm reporting this to The MathWorks, but thought readers of this group might be interested as well. -- Eric Durant http://www.edurant.com/