Prev: MCRInstaller.exe
Next: AR, MA, ARMA
From: Coby Metzger on 1 Jan 2008 05:03 beginner1.mat(a)hotmail.com wrote in message <37c5867e-e5fc- 4b04-884c-7dda096dc833(a)s8g2000prg.googlegroups.com>... > I am using an m-flie I made within another m-file and am coming up > with a 'Warning' that I don't quite understand: > > >In mfile1 at 25 > >In mfile2 at 60 > >Warning: Integer operands are required for colon operator when used as index > > Does anybody understand as to why it would point to the line below > since there is no colon operator in that line. > > > time=1:length(data).*(1/fs); > a=1; > b=step; > for i=1:floor(time) > x = data(a:b); > a = a+step; > b = b+step; > Y = fft(x,512); > PY= (Y.*conj(Y))/512;%% WARNING IS POINTING TO THIS LINE > PY_half = PY(1:(512/2)+1); > freq = fs*(0:(512/2))/512; > PY_all(1,i)= PY_half(1) > end I had a similar problem. Came out that the error was in the following line (where I used indices that were not integer) and matlab put the warning on the wrong line !!
From: John D'Errico on 1 Jan 2008 06:22 "Coby Metzger" <coby(a)ornim.com> wrote in message <fld35a$9v8$1(a)fred.mathworks.com>... > I had a similar problem. Came out that the error was in the > following line (where I used indices that were not integer) > and matlab put the warning on the wrong line !! I'll claim that there are two reasons why Matlab will place the error on the wrong line, and both are the fault of the user. 1. If you have not saved the file after making changes to it. So now Matlab is showing a non-current version of your file in the editor. Any errors will get flagged as the wrong line. 2. If you have saved the file, but in a bad place. NEVER use the Matlab toolbox directories as a repository for your own m-files. Matlab caches the files in those directories, so it will not see changes to them. Now when an error occurs and you have changed a file, matlab will not accurately know where that error originated. Both of these errors are user induced. Learn better habits and they will go away. John
From: cobymetz on 2 Jan 2008 07:49
On Jan 1, 1:22 pm, "John D'Errico" <woodch...(a)rochester.rr.com> wrote: > "Coby Metzger" <c...(a)ornim.com> wrote in message > > <fld35a$9v...(a)fred.mathworks.com>... > > > I had a similar problem. Came out that the error was in the > > following line (where I used indices that were not integer) > > and matlab put the warning on the wrong line !! > > I'll claim that there are two reasons why Matlab > will place the error on the wrong line, and both > are the fault of the user. > > 1. If you have not saved the file after making > changes to it. So now Matlab is showing a > non-current version of your file in the editor. > Any errors will get flagged as the wrong line. > > 2. If you have saved the file, but in a bad place. > NEVER use the Matlab toolbox directories as a > repository for your own m-files. Matlab caches > the files in those directories, so it will not see > changes to them. Now when an error occurs > and you have changed a file, matlab will not > accurately know where that error originated. > > Both of these errors are user induced. Learn > better habits and they will go away. > > John Sorry, John, but I did not do any of the mistakes you suggest. A third mistake would be not using the latest matlab version (I use 7.1.0.246 (R14) Service Pack 3) and did not have good reason to upgrade from there. Try to run the following lines in a script I named temp.m a=1:100; b=a; c=a(0.5:0.9); Even though the error is clearly in line 3 I get : Warning: Integer operands are required for colon operator when used as index. > In temp at 2 I am curious if this is the situation on other installations.as well. Coby. |