## 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-

The arrow indicating where the error occurs is under the

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!

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-

**))+...*dx^2;**__1__The arrow indicating where the error occurs is under the

**shown bold and underlined.**__1__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!

Cheers

Greg Locock

New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?

## RE: GNU Octave Syntax Error- Help!

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!

## RE: GNU Octave Syntax Error- Help!

"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))))

=h(L,check(m,n+7*(o-1)),Ts(m,n+7*(o-1)), Tinf(m,n+7*(o-1)));<<error here>>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!

Thanks again for the help.

## RE: GNU Octave Syntax Error- Help!

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