From bug-octave-request Tue Jun 22 15:53:32 1993 Subject: strange error From: A. Scottedward Hodel To: bug-octave Date: Tue, 22 Jun 93 15:53:27 CDT The m-files below behave quite strangely under octave: The main routine sets up a Lyapunov equation; the lyap subroutine just tries to evaluate argument dimensions. In the file lyap.m, if the line marked "uncomment the next line" is uncommented, then a value of $X = 1$ is returned, but no disp statements after 'dimension check to start' are printed out. If the line is left commented out, then 'error: X undefined' is printed out. I've tried this example both on a DELL '386 running Unix and on the Sparc stations at Auburn. Consistent behavior between them. Judging from the Matlab output, I'd guess that octave elseif and matlab elseif parse differently. Some wise souls would call this a feature instead of a bug. main.m:------------------------------------------------------------------ a = [1 2; 3 4] b =[1 1; 1 1] lyap(a,b) disp('exiting mainroutine') lyap.m:------------------------------------------------------------------ function X = lyap(A, B) disp('lyap: enter') C = B; B = A'; [ma,na] = size(A) [mb,nb] = size(B) [mc,nc] = size(C) %uncomment the next line to get rid of the error %X = 1; disp('dimension check to start:') if( (ma ~= na) | (mb ~= nb) | (mc ~= ma) | (nc ~= mb)) disp('illegal dimensions') X = 2; % error('Dimensions do not agree.') elseif (ma==0) disp('ma is 0') X = 3; return end end disp('end of lyap; never printed out') X = []; Matlab output: (with the line commented out) >> main a = 1 2 3 4 b = 1 1 1 1 lyap: enter ma = 2 na = 2 mb = 2 nb = 2 mc = 2 nc = 2 dimension check to start: end of lyap; never printed out ans = [] exiting mainroutine