Октава сообщает о двух видах ошибок для некорректных программ.
Ошибка синтаксического анализа возникает, если Octave не может понять что-то, что вы набрали. Например, если вы неправильно написали ключевое слово,
octave:13> function z = f (x, y) z = x ||| 2; endfunction
Октава немедленно ответит таким сообщением:
parse error: syntax error >>> function z = f (x, y) z = x ||| y; endfunction ^
Для большинства ошибок разбора Octave использует каретку (‘^‘), чтобы отметить точку на линии, где он не смог понять ваш ввод. В этом случае Octave сгенерировал сообщение об ошибке, потому что ключевое слово для логического или оператора ( ||
) было написано с ошибкой. Он отметил ошибку на третьем ‘|‘ потому что код, ведущий к этому, был правильным, но окончательным ‘|‘ не было понято.
Другой класс сообщений об ошибках возникает во время оценки. Эти ошибки называются ошибками времени выполнения или иногда ошибками оценки , потому что они возникают, когда ваша программа выполняется или оценивается . Например, если после исправления ошибки в предыдущем определении функции вы наберете
octave:13> f ()
Октава ответит
error: `x error: called from: error: f at line 1, column 22
Это сообщение об ошибке состоит из нескольких частей и дает довольно много информации,которая поможет вам найти источник ошибки.Сообщения генерируются из точки самой сокровенной ошибки и обеспечивают трассировку вложенных выражений и вызовов функций.
В приведенном выше примере первая строка указывает,что переменная с именем ‘x‘ оказалось неопределенным рядом со строкой 1 и столбцом 24 какой-то функции или выражения. Для ошибок, возникающих внутри функций, строки отсчитываются от начала файла, содержащего определение функции. Для ошибок, возникающих за пределами объемлющей функции, номер строки указывает номер входной строки, который обычно отображается в основной строке подсказки.
Вторая и третья строки сообщения об ошибке указывают, что ошибка произошла в функции f
. Если бы функция f
была вызвана из другой функции, например g
, список ошибок закончился бы еще одной строкой:
error: g at line 1, column 17
Эти списки вызовов функций позволяют довольно легко проследить путь,пройденный вашей программой до возникновения ошибки,и исправить ошибку перед повторной попыткой.
Octave reports two kinds of errors for invalid programs.
A parse error occurs if Octave cannot understand something you have typed. For example, if you misspell a keyword,
octave:13> function y = f (x) y = x***2; endfunction
Octave will respond immediately with a message like this:
parse error: syntax error >>> function y = f (x) y = x***2; endfunction ^
For most parse errors, Octave uses a caret (‘^’) to mark the point on the line where it was unable to make sense of your input. In this case, Octave generated an error message because the keyword for exponentiation (**
) was misspelled. It marked the error at the third ‘*’ because the code leading up to this was correct but the final ‘*’ was not understood.
Another class of error message occurs at evaluation time. These errors are called run-time errors, or sometimes evaluation errors, because they occur when your program is being run, or evaluated. For example, if after correcting the mistake in the previous function definition, you type
octave:13> f ()
Octave will respond with
error: `x' undefined near line 1 column 24 error: called from: error: f at line 1, column 22
This error message has several parts, and gives quite a bit of information to help you locate the source of the error. The messages are generated from the point of the innermost error, and provide a traceback of enclosing expressions and function calls.
In the example above, the first line indicates that a variable named ‘x’ was found to be undefined near line 1 and column 24 of some function or expression. For errors occurring within functions, lines are counted from the beginning of the file containing the function definition. For errors occurring outside of an enclosing function, the line number indicates the input line number, which is usually displayed in the primary prompt string.
The second and third lines of the error message indicate that the error occurred within the function f
. If the function f
had been called from within another function, for example, g
, the list of errors would have ended with one more line:
error: g at line 1, column 17
These lists of function calls make it fairly easy to trace the path your program took before the error occurred, and to correct the error before trying again.
© 1996–2020 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/v6.3.0/Errors.html
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS
Contact US
Thanks. We have received your request and will respond promptly.
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.
Students Click Here
GNU Octave Syntax Error- Help!GNU Octave Syntax Error- Help!(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 FilesOctave-3.6.4shareoctave3.6.4mbathdrain.m 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! Red Flag SubmittedThank you for helping keep Eng-Tips Forums free from inappropriate posts. |
ResourcesLearn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now Examine how the principles of DfAM upend many of the long-standing rules around manufacturability — allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now Metal 3D printing has rapidly emerged as a key technology in modern design and manufacturing, so it’s critical educational institutions include it in their curricula to avoid leaving students at a disadvantage as they enter the workforce. Download Now This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now |
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:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More…
Register now while it’s still free!
Already a member? Close this window and log in.
Join Us Close