Octave Syntax Error End Function
Contents |
in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Parse error? Hi everyone, This is a bit of a long winded question: I am having problems with my code. I can't seem to get by it. Basically I am wanting to read in a file, do some analysis on it and then have a plot octave function undefined near line 1 column 1 output. The piece of code below first reads in the file, splits the file into vectors and then the octave function argument undefined analysis. The function aver calculates the running mean of the data which, has many peaks. The idea is to find the points in the data set that just cross octave function example the running mean. I then want to fit a curve to the peak and find the maximum. This is essentially a peak finiding program. function gn = groupindcnt(filename); f = dlmread(filename); lambda = f(2:end,1); power = f(2:end,2:21); runmean = aver(lambda, power); %This for loop will loop over all syntax error in octave the currents/columns in power for crnt = 1:1:20 data = power(:,crnt); sign = 1; cross = zeros(1000,1); n = 1; %This bit is finding the data points just above and below the running mean. %and places a 1 in the vector cross. for i = 1:1:9000 if (sign*(data(i+499)-runmean(i,crnt)) > 0) sign = -1*sign; cross(i) = 1; n = n + 1; end end %This bit is to remove the false crossing points,
Syntax Error End Octave
peaks are typically 30 data %points wide. for j = 1:1:length(cross) if (cross(j)==1) cross(j+1) = 0; cross(j+2) = 0; cross(j+3) = 0; cross(j+4) = 0; cross(j+5) = 0; cross(j+6) = 0; cross(j) = j; end end %removing zeros from cross cross(cross==0)=[]; data_cp = data(cross+499,:); lambda_cp = lambda(cross+499); %This is the bit I am having problems with, it runs through all of the crossing points %and calculates if between two crossing points there is a maximum (the if statement). for k = 2:1:length(cross)-1 cp = (499+ cross(k) + round((cross(k+1) - cross(k))/2)); ll = data((499 + cross(k))); hl = data((499 + cross(k+1))); ml = data(cp); if (ml > ((hl+ll)/2) %ANYTHING ADDED IN HERE RETURNS PARSE ERROR %This is where I want to do the curve fitting end end end end This may be a bit hard to understand; it is dificult reading other peoples code I know! Basically anything I put in the IF statement causes a 'parse' error. Any suggestions? Cheers Martin Still learning everyday. Jaroslav Hajek-2 Reply | Threaded Open this post in threaded view ♦
| Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ The parse error on the "x" [SOLVED]
The First Line Of Error Message Indicates Traceback
This post was updated on . Hi everybody, I am a the first line of error message indicates in python newby at Octave, I am trying to solve a one order differential equation. Thats my code: function octave comment y = f (x,t) y = 5-2x; endfunction first = 2; t - linspace(0,20,100) s = lsode("f","first",t); plot(t,s,"r-") And this is my error: http://octave.1599824.n4.nabble.com/Parse-error-td2322504.html parse error near line 2 of file .../dif.m syntax error >>> y = 5-2x; ^ Help please bpabbott Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: The parse error on the "x" Administrator On Feb 1, 2013, at 3:33 PM, Taban <[hidden email]> wrote:Hi everybody, I http://octave.1599824.n4.nabble.com/The-parse-error-on-the-quot-x-quot-SOLVED-td4649365.html am a newby at Octave, I am trying to solve a one order differential equation. Thats my code: function y = f (x,t)
y = 5-2x;
endfunction
first = 2;
t - linspace(0,20,100)
s = lsode("f","first",t);
plot(t,s,"r-") And this is my error: parse error near line 2 of file .../dif.m syntax error >>> y = 5-2x; ^You neglected to multiplyy = 5 - 2 * x;Ben _______________________________________________ Help-octave mailing list [hidden email] https://mailman.cae.wisc.edu/listinfo/help-octave Taban Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: The parse error on the "x" It is a stupid error. I am feeling very silly. But now , it is giving this error: parse error near line 4 of file /home/taban/octave-matlab/denemeler/dif.m syntax error >>> first = 2; ^ Thanks for reply Alec Teal Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: The parse error on the "x" first could be a keyword, try something else. On 01/0
sessions, or in external files, and can be called just like built-in ones. Defining Functions In its simplest form, the definition of a function named name looks like this: function name body endfunction A valid function name is like a valid variable name: https://www.chemie.fu-berlin.de/chemnet/use/info/octave/octave_6.html a sequence of letters, digits and underscores, not starting with a digit. Functions share the same pool of names as variables. The function body consists of Octave statements. It is the most important part of the definition, because it http://www.eng-tips.com/viewthread.cfm?qid=345942 says what the function should actually do. For example, here is a function that, when executed, will ring the bell on your terminal (assuming that it is possible to do so): function wakeup printf ("\a"); endfunction The printf statement syntax error (see section Input and Output) simply tells Octave to print the string "\a". The special character `\a' stands for the alert character (ASCII 7). See section String Constants. Once this function is defined, you can ask Octave to evaluate it by typing the name of the function. Normally, you will want to pass some information to the functions you define. The syntax for passing parameters to a function in Octave is function name (arg-list) body endfunction where arg-list is syntax error end a comma-separated list of the function's arguments. When the function is called, the argument names are used to hold the argument values given in the call. The list of arguments may be empty, in which case this form is equivalent to the one shown above. To print a message along with ringing the bell, you might modify the beep to look like this: function wakeup (message) printf ("\a%s\n", message); endfunction Calling this function using a statement like this wakeup ("Rise and shine!"); will cause Octave to ring your terminal's bell and print the message `Rise and shine!', followed by a newline character (the `\n' in the first argument to the printf statement). In most cases, you will also want to get some information back from the functions you define. Here is the syntax for writing a function that returns a single value: function ret-var = name (arg-list) body endfunction The symbol ret-var is the name of the variable that will hold the value to be returned by the function. This variable must be defined before the end of the function body in order for the function to return a value. For example, here is a function that computes the average of the elements of a vector: function retval = avg (v) retval = sum (v) / length (v); endfunction If we had written avg like this instead, function retval = avg (v) if (is_vec
FORUMSFOR ENGINEERING PROFESSIONALS Log In Come Join Us! Are you anEngineering professional?Join Eng-Tips Forums! Talk With Other Members Be Notified Of ResponsesTo Your Posts Keyword Search One-Click Access To YourFavorite Forums Automated SignaturesOn Your Posts Best Of All, It's Free! Join Us! *Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting Guidelines Promoting, selling, recruiting, coursework and thesis posting is forbidden.Eng-Tips Posting Policies Jobs Link To This Forum! Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.Just copy and paste the BBCode HTML Markdown MediaWiki reStructuredText code below into your site. -Engineering programs/apps (general) Forum at Eng-Tips HomeForumsEngineering Computer ProgramsEngineering Programs-Engineering programs/apps (general) Forum GNU Octave Syntax Error- Help! thread724-345942 Forum Search FAQs Links MVPs GNU Octave Syntax Error- Help! GNU Octave Syntax Error- Help! Mechomatic (Mechanical) (OP) 31 May 13 17:46 Hello all- I've recently installed GNU Octave 3.6.4 on my Windows XP workstation and have been plugging along smoothly on a heat transfer FEA problem. I'm getting a syntax error back from Octave but I can't understand why. Attached is a folder of the .m files needed for the script (bathdrain.m). If somebody more familiarw ith the program could point me in the right direction, I would very much appreciate it! Here's the error that Octave spits out at me: parse error near line 104 of file C:\Program Files\Octave-3.6.4\share\octave\3.6.4\m\bathdrain.m syntax error >>> C(i,nodematnum(m,n+7*(o-1)))= k*2*z(m,n+7*(o-1))*dx^2/dz + k*(xu(m,n+7*(o-1))+xd(m,n+7*(o-1))+...*dx^2; The arrow indicating where the error occurs is under the 1 shown bold and underlined. The script is finding the temperature profile of a steel plate subjected to forced convection in cold air, free convection, and forced convection in hot water. I set up a cell array to model the mesh nodes and converted it to a matrix, then am using the cell array indices m, n,