From help-request at octave dot org Tue Dec 14 20:00:02 2004 Subject: Re: Question re function in .m file From: Paul Kienzle To: "John B. Thoo" Cc: octave help mailing list Date: Tue, 14 Dec 2004 21:01:24 -0500 These are expected errors. When you type the function f directly into octave it defines the function f. When you put it into quaderror.m it defines the function quaderror.m, which when loaded finds that it is named f and warns you. The x undefined error is because you didn't use quaderror(x), but instead called it without any arguments. If you said 'f' on the command line after defining f directly on the command line you would have seen a similar error. - Paul On Dec 14, 2004, at 6:44 PM, John B. Thoo wrote: > Hi. I apologize if this is a FAQ. I put the following in a file I > named "quaderror.m". > > function y = f(x) > y = (cos (x) - 0.5 * (sin (x)).^2 - (cos (x)).^2).^2; > endfunction > > But when I type "quaderror" in Octave, I get this: > > octave:9> quaderror > warning: near line 9, column 1: > > >>> quaderror > > > warning: function name `f' does not agree with function file name > `/Users/jbthoo/Documents/Work/CompletedWork/Reviews/ > PRIMUSreview200412/quaderror.m' > error: `x' undefined near line 2 column 11 > error: evaluating argument list element number 1 > error: evaluating binary operator `-' near line 2, column 14 > error: evaluating binary operator `-' near line 2, column 35 > error: evaluating binary operator `.^' near line 2, column 50 > error: evaluating assignment expression near line 2, column 3 > error: called from `quaderror' in file > `/Users/jbthoo/Documents/Work/CompletedWork/Reviews/ > PRIMUSreview200412/quaderror.m' > > I don't understand the error messages. When I type the function > directly in Octave, I do not get an error. What am I missing? > > TIA. > ---John. > > > > ------------------------------------------------------------- > 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 > ------------------------------------------------------------- > ------------------------------------------------------------- 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 -------------------------------------------------------------