INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*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.

Jobs

GNU Octave Syntax Error- Help!

GNU Octave Syntax Error- Help!

(OP)
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, and o to map the adjacent node temperatures. In the error, matrix "nodematnum" is a matrix relating a unique index number to each actual node (empty nodes are numbered 1 and used a cell padding so that matrix indices work when running the loops to create a coefficient matrix).

I'm not sure why it's getting a syntax error on the 1, but if somebody who's more knowledgeable could set me straight, I'd appreciate it!

RE: GNU Octave Syntax Error- Help!

Problem is actually in the line before. Look closely at the parentheses in the if statement. A text editor that highlights matching parentheses makes this easier. I think there's at least one missing closing parenthesis in the if statement, and maybe a pair of them too.

In general, the syntax checker can only do so much - unmatched delimiters can send it way off the mark. When fault finding, reduce the code to the last known good state, and add in new things one at a time. Will narrow your search considerably!

RE: GNU Octave Syntax Error- Help!

(OP)
Thank you! It was quite obviously the end of the work day on Friday when I was working on that. I appreciate the help with finding my error!

RE: GNU Octave Syntax Error- Help!

(OP)
Of course, I turn around to fix something else and I break the script again...

"error: subscript indices must be either positive integers or logicals"

Error on line 92, col 37.

h(int8(abs(m)),int8(abs(n+7*(o-1)))) <<error here>> =h(L,check(m,n+7*(o-1)),Ts(m,n+7*(o-1)), Tinf(m,n+7*(o-1)));

I have added the int8() and abs() functions to guarantee the system was reading the indices as positive integers, but received the same error with and without those added functions. The code section is a set of nested for loops: for o=2:4, for n=2:6, and for m=2:15. These counters and indices are used elsewhere in the script with no issue. Matrix h is pre-sized as h=zeros(16,25). I inserted two lines of debugging code to see when the script breaks (displays the counters m,n,o and what they compute to (m,n+7*(o-1)) to see on what pass the code breaks and to ensure they are producing useable indices). The code breaks on the first pass at o=2,n=2,m=2 (indices show (2,9)). The script works with this problem line of code commented out, and the counters and indices run through the for loops just fine.

Thoughts on why Octave is being so problematic?

RE: GNU Octave Syntax Error- Help!

(OP)
Found my error. Note to self, don't try to name a variable the same as a function...

Thanks again for the help.

RE: GNU Octave Syntax Error- Help!

Note to WPratsi:

Be careful with built-ins too, like i and j. i is a common indexing variable in many languages, but all bets are off when it somehow becomes sqrt(-1).

BTW, your code (what you have shown) looks like it could probably be written in a single line, with no loops.

- Steve

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close