Mercurial > hg > octave-lyh
annotate doc/faq/Octave-FAQ.texi @ 8325:b93ac0586e4b
spelling corrections
Here is a patch with some spelling corrections to the manual.
changeset: 8308:aeaf884ea9af
user: Brian Gough <bjg@gnu.org>
date: Fri Nov 07 09:26:17 2008 -0500
summary: [docs] assoicated => associated
author | Brian Gough<bjg@network-theory.co.uk> |
---|---|
date | Mon, 17 Nov 2008 11:38:39 +0100 |
parents | 242756f065f0 |
children | 70dd33450061 |
rev | line source |
---|---|
7018 | 1 % Copyright (C) 1997, 1998, 1999, 2001, 2003, 2004, 2005, 2007 John W. Eaton |
2 % | |
3 % This file is part of Octave. | |
4 % | |
5 % Octave is free software; you can redistribute it and/or modify it | |
6 % under the terms of the GNU General Public License as published by the | |
7 % Free Software Foundation; either version 3 of the License, or (at | |
8 % your option) any later version. | |
9 % | |
10 % Octave is distributed in the hope that it will be useful, but WITHOUT | |
11 % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 % FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 % for more details. | |
14 % | |
15 % You should have received a copy of the GNU General Public License | |
16 % along with Octave; see the file COPYING. If not, see | |
17 % <http://www.gnu.org/licenses/>. | |
18 | |
2866 | 19 \input texinfo.tex @c -*-texinfo-*- |
20 | |
3030 | 21 @setfilename Octave-FAQ.info |
2866 | 22 @settitle Frequently asked questions about Octave (with answers) |
23 | |
24 @setchapternewpage off | |
5099 | 25 @direntry |
6584 | 26 * Octave-FAQ: (Octave-FAQ). Frequently asked questions about Octave |
5099 | 27 @end direntry |
2866 | 28 @titlepage |
29 @title Octave FAQ | |
30 @subtitle Frequently asked questions about Octave | |
8128 | 31 @subtitle September 2008 |
2866 | 32 @sp 1 |
6900 | 33 @author John W. Eaton and David Bateman |
2866 | 34 @page |
35 @end titlepage | |
36 | |
5423 | 37 @ifnottex |
4830 | 38 @node Top |
2866 | 39 @top |
40 @unnumbered Preface | |
41 @cindex FAQ for Octave, latest version | |
5423 | 42 @end ifnottex |
2866 | 43 |
44 This is a list of frequently asked questions (FAQ) for Octave users. | |
45 | |
6584 | 46 We are always looking for new questions (@emph{with} answers), better |
47 answers, or both. Please send suggestions to @email{bug@@octave.org}. | |
48 If you have general questions about Octave, or need help for something | |
49 that is not covered by the Octave manual or the FAQ, please use the | |
50 @email{help@@octave.org} mailing list. | |
2866 | 51 |
52 This FAQ is intended to supplement, not replace, the Octave manual. | |
6584 | 53 Before posting a question to the @email{help@@octave.org} mailing list, |
54 you should first check to see if the topic is covered in the manual. | |
2866 | 55 |
56 @menu | |
6583 | 57 * What is Octave?:: |
58 * How can I cite Octave?:: | |
8128 | 59 * Series 3.0.N:: |
6583 | 60 * Octave Features:: |
61 * Learning more about Octave:: | |
62 * Getting Octave:: | |
63 * Installation:: | |
2866 | 64 * Common problems:: |
6584 | 65 * How do I ...?:: |
6583 | 66 * MATLAB compatibility:: |
2866 | 67 * Index:: |
68 @end menu | |
69 | |
4830 | 70 @node What is Octave? |
2866 | 71 @chapter What is Octave? |
72 | |
73 Octave is a high-level interactive language, primarily intended for | |
74 numerical computations that is mostly compatible with | |
75 @sc{Matlab}.@footnote{@sc{Matlab} is a registered trademark of The MathWorks, | |
6583 | 76 Inc.} |
2866 | 77 |
6583 | 78 Octave can do arithmetic for real, complex or integer-valued scalars |
79 and matrices, solve sets of nonlinear algebraic equations, integrate | |
80 functions over finite and infinite intervals, and integrate systems of | |
81 ordinary differential and differential-algebraic equations. | |
2866 | 82 |
83 Octave uses the GNU readline library to handle reading and editing | |
84 input. By default, the line editing commands are similar to the | |
85 cursor movement commands used by GNU Emacs, and a vi-style line | |
86 editing interface is also available. At the end of each session, the | |
87 command history is saved, so that commands entered during previous | |
88 sessions are not lost. | |
89 | |
6879 | 90 The Octave distribution includes a 590+ page Texinfo manual. Access |
2866 | 91 to the complete text of the manual is available via the help command |
6583 | 92 @c really, the *complete* text? |
2866 | 93 at the Octave prompt. |
94 | |
6583 | 95 @menu |
96 * Who develops Octave?:: | |
6584 | 97 * Why GNU Octave?:: |
6583 | 98 * What version should I use?:: |
99 * On what platforms does Octave run?:: | |
100 @end menu | |
101 | |
102 @node Who develops Octave? | |
103 @section Who develops Octave? | |
104 | |
6584 | 105 Discussions about writing the software that would eventually become |
106 Octave started in about 1988 with James B. Rawlings and John W. Eaton at | |
107 the University of Texas. John W. Eaton was the original author of | |
108 Octave, starting full-time development in February 1992. He is still | |
109 the primary maintainer. The community | |
110 of users/developers has in addition contributed some code and fuels the | |
111 discussion on the mailing lists @email{help@@octave.org} (user forum), | |
112 @email{bug@@octave.org} (bug reports), @email{maintainers@@octave.org} | |
113 (development issues), and @email{octave-dev@@lists.sourceforge.net} (all | |
114 things related to the Octave Forge repository of user-contributed | |
115 functions). | |
6583 | 116 |
6584 | 117 @node Why GNU Octave? |
118 @section Why GNU Octave? | |
6583 | 119 |
6584 | 120 The GNU Project was launched in 1984 to develop a complete Unix-like |
121 operating system which is free software: the GNU system. | |
122 | |
123 GNU is a recursive acronym for ``GNU's Not Unix''; it is pronounced | |
124 guh-noo, approximately like canoe. | |
6583 | 125 |
6584 | 126 The Free Software Foundation (FSF) is the principal organizational |
127 sponsor of the GNU Project. | |
128 | |
129 Octave became GNU Octave in 1997 (beginning with version 2.0.6). This | |
130 meant agreeing to consider Octave a part of the GNU Project and support | |
131 the efforts of the FSF. However, Octave is not and has never been | |
132 developed by the FSF. | |
133 | |
134 For more information about the GNU project, see @url{www.gnu.org}. | |
6583 | 135 |
136 @cindex FSF [Free Software Foundation] | |
137 @cindex GNU [GNU's not unix] | |
138 | |
139 @node What version should I use? | |
140 @section What version should I use? | |
141 | |
142 In general, you will find the latest version on | |
6584 | 143 @url{http://www.octave.org/download.html}. It is |
6583 | 144 recommended to use the ``testing'' version of octave for general use, |
145 and the ``development'' version if you want the latest features. | |
146 | |
147 A list of user-visible changes since the last release is available in | |
148 the file @file{NEWS}. The file @file{ChangeLog} in the source | |
149 distribution contains a more detailed record of changes made since the | |
150 last release. | |
151 | |
152 @node On what platforms does Octave run? | |
153 @section On what platforms does Octave run? | |
154 | |
6584 | 155 Octave runs on various Unices---at least Linux and Solaris, Mac OS X, |
156 Windows and anything you can compile it on. Binary distributions exist | |
6583 | 157 at least for Debian, Suse, Fedora and RedHat Linuxes (Intel and AMD |
158 CPUs, at least), for Mac Os X and Windows' 98, 2000 and XP. | |
159 | |
2866 | 160 Two and three dimensional plotting is fully supported using gnuplot. |
161 | |
162 The underlying numerical solvers are currently standard Fortran ones | |
163 like Lapack, Linpack, Odepack, the Blas, etc., packaged in a library | |
164 of C++ classes. If possible, the Fortran subroutines are compiled | |
165 with the system's Fortran compiler, and called directly from the C++ | |
166 functions. If that's not possible, you can still compile Octave if | |
167 you have the free Fortran to C translator f2c. | |
168 | |
169 Octave is also free software; you can redistribute it and/or modify it | |
170 under the terms of the GNU General Public License as published by the | |
171 Free Software Foundation. | |
172 | |
4830 | 173 @node How can I cite Octave? |
174 @chapter How can I cite Octave? | |
4831 | 175 |
176 Pointing to @url{http://www.octave.org} is good, because that gives | |
177 people a direct way to find out more. If citation of a URL is not | |
178 allowed by a publisher, or if you also want to point to a traditional | |
179 reference, then you can cite the Octave manual: | |
4830 | 180 |
181 @example | |
182 @group | |
6584 | 183 @@BOOK@{eaton:2002, |
184 author = "John W. Eaton", | |
185 title = "GNU Octave Manual", | |
186 publisher = "Network Theory Limited", | |
187 year = "2002", | |
188 isbn = "0-9541617-2-6" | |
189 @} | |
4830 | 190 @end group |
191 @end example | |
192 | |
8128 | 193 @node Series 3.0.N |
194 @chapter What's new in version series 3.0.N and 3.1.N of Octave | |
6583 | 195 |
8128 | 196 The 3.0.N series has enough new features to justify a major version |
197 number change. The 3.0.N series brings | |
6583 | 198 |
199 @itemize @bullet | |
200 | |
201 @item integer types | |
202 | |
203 @item fixed point arithmetic | |
204 | |
205 @item sparse matrices | |
206 | |
207 @item Linear programming code based on GLPK | |
208 | |
209 @item 64-bit compilation support | |
210 | |
211 @item gzipped files and stream and consequently support of matlab v7 files | |
2866 | 212 |
6583 | 213 @item better support for both msvc and mingw |
214 | |
7116 | 215 @item a fully compatible MEX interface |
6583 | 216 |
6606 | 217 @item many many other minor features and compatibility changes |
6583 | 218 |
219 @end itemize | |
220 | |
6735 | 221 Here are some features that have been around since 2.1.N |
6583 | 222 |
223 @itemize @bullet | |
2866 | 224 |
6583 | 225 @item NDarrays |
226 | |
227 @item cells | |
228 | |
229 @end itemize | |
230 | |
8128 | 231 The 3.1.N series is the current development release and will become a |
232 3.2.N release in the future. This series brings the new features | |
233 | |
234 @itemize | |
235 @item OpenGL backend | |
236 | |
237 An experimental OpenGL graphics backend to replace the gnuplot | |
238 | |
239 @item Object Orient Programming | |
240 | |
241 @item Block comments | |
242 | |
243 @item imwrite and imread | |
244 | |
245 The functions are based on the GraphicsMagick library. | |
246 | |
247 @item Lazy transpose | |
248 | |
249 Special treatment in the parser of things like "a' * b", where the | |
250 transpose is never explicitly formed but a flag is rather passed to the | |
251 underlying LAPACK code. | |
252 | |
253 @item Single precision type | |
8292 | 254 |
255 @item Improved array indexing | |
256 The underlying code used for indexing of arrays has been completely | |
257 rewritten and so the indexing of arrays is now significantly faster. | |
8128 | 258 @end itemize |
259 | |
260 | |
4830 | 261 @node Octave Features |
2866 | 262 @chapter What features are unique to Octave? |
263 | |
264 @menu | |
6583 | 265 * Functions defined on the command-line:: |
266 * Comments with #:: | |
267 * Strings delimitted by double quotes ":: | |
268 * Line continuation by backslash:: | |
269 * Informative block closing:: | |
270 * Coherent syntax:: | |
271 * Exclamation mark as not operator:: | |
2866 | 272 * Increment and decrement operators:: |
273 * Unwind-protect:: | |
6583 | 274 * Built-in ODE and DAE solvers:: |
2866 | 275 @end menu |
276 | |
8128 | 277 This section refers to Matlab R2008b and Octave 2.1.51. |
2866 | 278 |
6583 | 279 @node Functions defined on the command-line |
280 @section Functions defined on the command-line | |
2866 | 281 |
6583 | 282 Functions can be defined by entering code on the command line, a |
6584 | 283 feature not supported by the other leading brand. For example, you may |
6583 | 284 type: |
2866 | 285 |
286 @example | |
287 @group | |
6583 | 288 octave:1> function s = hello_string (to_who) |
289 > ## Say hello | |
290 > if nargin<1, to_who = "World"; end | |
291 > s = ["Hello ",\ | |
292 > to_who]; | |
293 > endfunction | |
294 octave:2> hello_string ("Moon") | |
295 ans = Hello Moon | |
2866 | 296 @end group |
297 @end example | |
298 | |
6583 | 299 @node Comments with # |
300 @section Comments with # | |
301 | |
6584 | 302 The pound character, @samp{#}, may be used to start comments, in addition |
303 to @samp{%}. See the previous example. The major advantage of this is | |
304 that as @samp{#} is also a comment character for unix script files, any | |
305 file that starts with a string like @samp{#! /usr/bin/octave -q} will be | |
306 treated as an octave script and be executed by octave. | |
2866 | 307 |
6583 | 308 @node Strings delimitted by double quotes " |
309 @section Strings delimitted by double quotes " | |
6584 | 310 The double quote, @samp{"}, may be used to delimit strings, in addition to |
311 the single quote @samp{'}. See the previous example. Also, double-quoted | |
312 strings include backslash interpretation (like C++, C, and Perl) while | |
313 single quoted are uninterpreted (like Matlab and Perl). | |
6583 | 314 |
315 @node Line continuation by backslash | |
316 @section Line continuation by backslash | |
317 | |
6584 | 318 Lines can be continued with a backslash, @samp{\}, in addition to three |
319 points @samp{@dots{}}. See the previous example. | |
6583 | 320 |
321 @node Informative block closing | |
322 @section Informative block closing | |
323 | |
6584 | 324 You may close @code{function}, @code{for}, @code{while}, @code{if}, |
325 @dots{} blocks with @code{endfunction}, @code{endfor}, @code{endwhile}, | |
326 @dots{} keywords in addition to using @code{end}. As with Matlab, the | |
327 @code{end} (or @code{endfunction}) keyword that marks the end of a | |
328 function defined in a @file{.m} file is optional. | |
2866 | 329 |
6583 | 330 @node Coherent syntax |
331 @section Coherent syntax | |
332 | |
333 Indexing other things than variables is possible, as in: | |
334 @example | |
335 @group | |
336 octave:1> [3 1 4 1 5 9](3) | |
337 ans = 4 | |
338 octave:2> cos([0 pi pi/4 7])(3) | |
339 ans = 0.70711 | |
340 @end group | |
341 @end example | |
342 | |
343 @node Exclamation mark as not operator | |
344 @section Exclamation mark as not operator | |
345 | |
346 The exclamation mark '!' (aka ``Bang!'') is a negation operator, just | |
347 like the tilde '~': | |
2866 | 348 |
349 @example | |
350 @group | |
6583 | 351 octave:1> if ! strcmp (program_name, "octave"), |
352 > "It's an error" | |
353 > else | |
354 > "It works!" | |
355 > end | |
356 ans = It works! | |
2866 | 357 @end group |
358 @end example | |
359 | |
4830 | 360 @node Increment and decrement operators |
2866 | 361 @section Increment and decrement operators |
362 | |
363 @cindex Increment operators | |
364 @cindex Decrement operators | |
365 @cindex Operators, increment | |
366 @cindex Operators, decrement | |
367 | |
6584 | 368 If you like the @samp{++}, @samp{+=} etc operators, rejoice! |
2866 | 369 Octave includes the C-like increment and decrement operators @samp{++} |
6583 | 370 and @samp{--} in both their prefix and postfix forms, in addition to |
371 @samp{+=}, @samp{-=}, @samp{*=}, @samp{/=}, @samp{^=}, @samp{.*=}, | |
372 @samp{./=}, and @samp{.^=}. | |
2866 | 373 |
374 For example, to pre-increment the variable @var{x}, you would write | |
375 @code{++@var{x}}. This would add one to @var{x} and then return the new | |
376 value of @var{x} as the result of the expression. It is exactly the | |
377 same as the expression @code{@var{x} = @var{x} + 1}. | |
378 | |
6584 | 379 To post-increment a variable @var{x}, you would write @code{x++}. |
2866 | 380 This adds one to the variable @var{x}, but returns the value that |
381 @var{x} had prior to incrementing it. For example, if @var{x} is equal | |
6584 | 382 to 2, the result of the expression @code{x++} is 2, and the new |
2866 | 383 value of @var{x} is 3. |
384 | |
385 For matrix and vector arguments, the increment and decrement operators | |
386 work on each element of the operand. | |
387 | |
388 | |
4830 | 389 @node Unwind-protect |
2866 | 390 @section Unwind-protect |
391 | |
392 @cindex Unwind-protect | |
393 | |
394 Octave supports a limited form of exception handling modelled after the | |
395 unwind-protect form of Lisp. The general form of an | |
396 @code{unwind_protect} block looks like this: | |
397 | |
398 @example | |
399 @group | |
400 unwind_protect | |
401 @var{body} | |
402 unwind_protect_cleanup | |
403 @var{cleanup} | |
404 end_unwind_protect | |
405 @end group | |
406 @end example | |
407 | |
408 @noindent | |
409 Where @var{body} and @var{cleanup} are both optional and may contain any | |
410 Octave expressions or commands. The statements in @var{cleanup} are | |
411 guaranteed to be executed regardless of how control exits @var{body}. | |
412 | |
413 The @code{unwind_protect} statement is often used to reliably restore | |
414 the values of global variables that need to be temporarily changed. | |
415 | |
8128 | 416 Matlab can be made to do something similar with their @code{OnCleanUp} |
417 function that was introduced in 2008a. | |
418 | |
4830 | 419 @node Built-in ODE and DAE solvers |
2866 | 420 @section Built-in ODE and DAE solvers |
421 | |
422 @cindex DASSL | |
423 @cindex LSODE | |
424 | |
425 Octave includes LSODE and DASSL for solving systems of stiff ordinary | |
426 differential and differential-algebraic equations. These functions are | |
427 built in to the interpreter. | |
428 | |
6583 | 429 @node Learning more about Octave |
430 @chapter What documentation exists for Octave? | |
431 | |
432 @menu | |
433 * Documentation:: | |
434 * Getting additional help:: | |
435 * User community:: | |
436 * Bug reports:: | |
437 @end menu | |
438 | |
439 | |
4830 | 440 @node Documentation |
6583 | 441 @section What documentation exists for Octave? |
2866 | 442 |
443 @cindex Octave, documentation | |
444 | |
6879 | 445 The Octave distribution includes a 590+ page manual that is also |
2866 | 446 distributed under the terms of the GNU GPL. |
6583 | 447 It is available on the web at |
448 @url{http://www.octave.org/docs.html} and you will also | |
449 find there instructions on how to order a paper version. | |
450 | |
451 The complete text of the Octave manual is also available using the GNU | |
452 Info system via the GNU Emacs, info, or xinfo programs, or by using | |
453 the @samp{help -i} command to start the GNU info browser directly from | |
454 the Octave prompt. | |
455 | |
456 If you have problems using this documentation, or find that some topic | |
457 is not adequately explained, indexed, or cross-referenced, please send | |
6584 | 458 a bug report to @email{bug@@octave.org}. |
6583 | 459 |
2866 | 460 |
6583 | 461 @node Getting additional help |
462 @section Getting additional help | |
463 | |
464 @cindex Additional help | |
465 @cindex Mailing lists, help-octave | |
466 | |
6584 | 467 If you can't find an answer to your question, the |
468 @email{help@@octave.org} mailing list is available for questions related | |
469 to using, installing, and porting Octave that are not adequately | |
470 answered by the Octave manual or by this document. | |
6583 | 471 |
472 @node User community | |
473 @section User community | |
474 | |
6584 | 475 To subscribe to the list, go to @url{www.octave.org/archive.html} and |
476 follow the link to the subscription page for the list. | |
2866 | 477 |
6653 | 478 @strong{Please do not} send requests to be added or removed from the |
6583 | 479 mailing list, or other administrative trivia to the list itself. |
480 | |
481 An archive of old postings to the help-octave mailing list is maintained | |
482 on @url{http://www.octave.org/archive.html}. | |
483 | |
6584 | 484 You will also find some user advice and code spread over the web. Good |
6583 | 485 starting points are the Octave Wiki @url{http://wiki.octave.org} and |
7483
fb66330b2608
don't special case SH_LD for FreeBSD and OpenBSD
John W. Eaton <jwe@octave.org>
parents:
7116
diff
changeset
|
486 Octave-Forge @url{http://octave.sourceforge.net} |
6583 | 487 |
488 @node Bug reports | |
489 @section I think I have found a bug in Octave. | |
490 | |
491 @cindex Bug in Octave, newly found | |
492 | |
493 ``I think I have found a bug in Octave, but I'm not sure. How do I know, | |
494 and who should I tell?'' | |
2866 | 495 |
6583 | 496 @cindex Manual, for Octave |
497 | |
498 First, see the section on bugs and bug reports in the Octave manual. | |
499 When you report a bug, make sure to describe the type of computer you | |
500 are using, the version of the operating system it is running, and the | |
501 version of Octave that you are using. Also provide enough code so that | |
502 the Octave maintainers can duplicate your bug. | |
503 | |
504 If you have Octave working at all, the easiest way to do this is to use | |
505 the Octave function @code{bug_report}. When you execute this function, | |
506 Octave will prompt you for a subject and then invoke the editor on a | |
507 file that already contains all the configuration information. When you | |
508 exit the editor, Octave will mail the bug report for you (in a unix-like | |
509 operating system). | |
510 | |
511 @cindex Octave bug report | |
512 @cindex Mailing lists, bug-octave | |
513 | |
514 If for some reason you cannot use Octave's @code{bug_report} function, | |
6584 | 515 mail your bug report to @email{bug@@octave.org}. Your message needs to |
6583 | 516 include enough information to allow the maintainers of Octave to fix the |
517 bug. Please read the section on bugs and bug reports in the Octave | |
518 manual for a list of things that should be included in every bug report. | |
519 | |
2866 | 520 |
4830 | 521 @node Getting Octave |
6583 | 522 @chapter Getting Octave |
2866 | 523 |
524 @menu | |
6583 | 525 * Source code:: |
526 * Pre-compiled binary packages:: | |
527 * Octave for other platforms:: | |
2866 | 528 @end menu |
529 | |
6583 | 530 @node Source code |
531 @section Source code | |
532 @cindex Source code | |
2866 | 533 |
6583 | 534 Source code is available on the Octave development site, where you are |
535 sure to get the latest version. | |
2866 | 536 |
6583 | 537 @itemize @bullet |
538 @item @url{http://www.octave.org/download.html} | |
539 @item @url{ftp://ftp.octave.org/pub/octave/} | |
540 @end itemize | |
2866 | 541 |
6583 | 542 Since Octave is distrubted under the terms of the GPL, you can get |
543 Octave from a friend who has a copy, by anonymous FTP, or by ordering | |
544 a tape or CD-ROM from the Free Software Foundation (FSF). | |
2866 | 545 |
6583 | 546 @node Pre-compiled binary packages |
547 @section Pre-compiled binary packages | |
548 @cindex Pre-compiled binary packages | |
549 @cindex Binaries | |
2866 | 550 |
6584 | 551 The Octave project does not distribute binary packages, but other |
552 projects do. For an up-to-date listing of packagers, see: | |
2866 | 553 |
6583 | 554 @itemize @bullet |
555 @item @url{http://www.octave.org/download.html} | |
556 @item @url{http://wiki.octave.org/wiki.pl?CategoryInstall} | |
557 @end itemize | |
2866 | 558 |
6583 | 559 As of today, Octave binaries are available at least on Debian, RedHat, |
560 Suse and Fedora Linuxes, Mac OS X, Windows' 98, 2000 and XP. | |
2866 | 561 |
4830 | 562 @node Octave for other platforms |
2866 | 563 @section How do I get a copy of Octave for (some other platform)? |
564 | |
565 @cindex VMS support | |
566 @cindex VAX | |
567 @cindex MS-DOS support | |
3154 | 568 @cindex Windows support |
2866 | 569 @cindex DJGPP |
570 @cindex EMX | |
571 @cindex OS/2 support | |
572 | |
6879 | 573 Octave currently runs on Unix-like systems, Mac OS X, and Windows. |
574 It should be possible to make Octave work on other systems as well. | |
575 If you are interested in porting Octave to other systems, please contact | |
6584 | 576 @email{bug@@octave.org}. |
2866 | 577 |
6583 | 578 @c @menu |
579 @c * Octave for Unix:: | |
580 @c * Octave for other platforms:: | |
581 @c * latest versions:: | |
582 @c @end menu | |
2866 | 583 |
6583 | 584 @c @cindex Octave, ordering |
585 @c @cindex Octave, getting a copy | |
2866 | 586 |
4830 | 587 @node Installation |
2866 | 588 @chapter Installation Issues and Problems |
589 | |
590 @cindex Octave, building | |
591 | |
8128 | 592 Octave 3.2 require approximately 800MB of disk storage to unpack |
6584 | 593 and compile from source (considerably less if you don't compile with |
594 debugging symbols). Once installed, Octave requires approximately 200MB | |
595 of disk space (again, considerably less if you don't compile with | |
596 debugging symbols). | |
2866 | 597 |
598 @menu | |
599 * What else do I need?:: | |
600 * Other C++ compilers?:: | |
601 @end menu | |
602 | |
4830 | 603 @node What else do I need? |
2866 | 604 @section What else do I need? |
605 | |
606 @cindex GNU gcc | |
607 @cindex GNU g++ | |
608 @cindex libg++ | |
609 @cindex GNU Make | |
610 @cindex Flex | |
611 @cindex GNU Bison | |
612 | |
3154 | 613 To compile Octave, you will need a recent version of GNU Make. You |
6584 | 614 will also need GCC 3.3 or later, although GCC 4.1 or later is |
615 recommended. | |
3154 | 616 |
6584 | 617 @strong{You must have GNU Make to compile octave}. Octave's Makefiles |
3154 | 618 use features of GNU Make that are not present in other versions of make. |
619 GNU Make is very portable and easy to install. | |
2866 | 620 |
4830 | 621 @node Other C++ compilers? |
2866 | 622 @section Can I compile Octave with another C++ compiler? |
623 | |
6584 | 624 Yes, but development is done primarily with GCC, so you may hit some |
625 incompatibilities. Octave is intended to be portable to any standard | |
626 conforming compiler. If you have difficulties that you think are bugs, | |
627 please report them to the @email{bug@@octave.org} mailing list, or ask | |
628 for help on the @email{help@@octave.org} mailing list. | |
2866 | 629 |
4830 | 630 @node Common problems |
2866 | 631 @chapter Common problems |
632 | |
633 This list is probably far too short. Feel free to suggest additional | |
634 questions (preferably with answers!) | |
635 | |
636 @itemize @bullet | |
637 @item | |
638 Octave takes a long time to find symbols. | |
639 | |
6606 | 640 Octave uses the @code{genpath} function to recursively add directories |
6900 | 641 to the list of directories searched for function files. Check the list |
6606 | 642 of directories with the @code{path} command. If the path list is very |
643 long check your use of the @code{genpath} function. | |
6735 | 644 |
645 @item | |
6900 | 646 When plotting Octave occasionally gives me errors like @samp{gnuplot> 9 0.735604 |
647 line 26317: invalid command}. | |
6735 | 648 |
649 There is a known bug in gnuplot 4.2 that can cause an off by one error | |
650 while piping data to gnuplot. The relevant gnuplot bug report can be | |
651 found at @url{http://sourceforge.net/tracker/index.php?func=detail&aid=1716556&group_id=2055&atid=102055} | |
652 | |
653 If you have obtained your copy of Octave from a distribution please file | |
654 a bug report requesting that the fix reported in the above bug report be | |
655 included. | |
8215
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
656 |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
657 @item |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
658 I cannot install a package. Octave complains about a missing @code{mkoctfile}. |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
659 |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
660 Most distributions split Octave into several packages. The script |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
661 @code{mkoctfile} is then part of a separate package: |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
662 @itemize @minus |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
663 @item |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
664 Debian/Ubuntu |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
665 |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
666 @code{aptitude install octave3.0-headers} |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
667 |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
668 @item |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
669 Fedora |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
670 |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
671 @code{yum install octave-devel} |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
672 |
518789a0539d
FAQ entry about split development packages in distributions
Thomas Weber <thomas.weber.mail@gmail.com>
parents:
8130
diff
changeset
|
673 @end itemize |
2866 | 674 @end itemize |
675 | |
6584 | 676 @node How do I ...? |
677 @chapter How do I ...? | |
2866 | 678 |
6583 | 679 @menu |
680 * How do I set the number of displayed decimals?:: | |
681 @end menu | |
2866 | 682 |
6583 | 683 @cindex Tips and tricks |
6584 | 684 @cindex How do I @dots{} ? |
2866 | 685 |
6583 | 686 @node How do I set the number of displayed decimals? |
687 @section How do I set the number of displayed decimals? | |
2866 | 688 |
689 @example | |
690 @group | |
6583 | 691 octave:1> format long |
692 octave:2> pi | |
693 pi = 3.14159265358979 | |
694 octave:3> format short | |
695 octave:4> pi | |
696 pi = 3.1416 | |
2866 | 697 @end group |
698 @end example | |
699 | |
4830 | 700 @node MATLAB compatibility |
2866 | 701 @chapter Porting programs from @sc{Matlab} to Octave |
702 | |
703 @cindex @sc{Matlab} compatibility | |
704 @cindex Compatibility with @sc{Matlab} | |
705 | |
6612 | 706 People often ask |
707 | |
2866 | 708 ``I wrote some code for @sc{Matlab}, and I want to get it running under |
709 Octave. Is there anything I should watch out for?'' | |
710 | |
6612 | 711 or alternatively |
712 | |
713 ``I wrote some code in Octave, and want to share it with @sc{Matlab} | |
6900 | 714 users. Is there anything I should watch out for?'' |
6612 | 715 |
6900 | 716 which is not quite the same thing. There are still a number of |
6612 | 717 differences between Octave and @sc{Matlab}, however in general |
718 differences between the two are considered as bugs. Octave might | |
719 consider that the bug is in @sc{Matlab} and do nothing about it, but | |
720 generally functionality is almost identical. If you find a difference | |
721 between Octave behavior and @sc{Matlab}, then you should send a | |
722 description of this difference (with code illustrating the difference, | |
723 if possible) to @email{bug@@octave.org}. | |
724 | |
725 Furthermore, Octave adds a few syntactical extensions to Matlab that | |
726 might cause some issues when exchanging files between Matlab and Octave | |
727 users. As both Octave and @sc{Matlab} are under constant development the | |
728 information in this section is subject to change at anytime. | |
729 | |
730 You should also look at the page | |
731 @url{http://octave.sourceforge.net/packages.html} and | |
732 @url{http://octave.sourceforge.net/doc/} that has a function reference | |
733 that is up to date. You can use this function reference to see the | |
734 number of octave function that are available and their @sc{Matlab} | |
735 compatibility. | |
736 | |
8128 | 737 The major differences between Octave 3.2.N and @sc{Matlab} R2008a are: |
6612 | 738 |
739 @itemize @bullet | |
740 @item Nested Functions | |
741 | |
6900 | 742 Octave doesn't yet have nested functions. That is |
2866 | 743 |
6612 | 744 @example |
745 @group | |
746 function y = foo (x) | |
6900 | 747 y = bar(x) |
748 function y = bar (x) | |
749 y = @dots{}; | |
750 end | |
6612 | 751 end |
752 @end group | |
753 @end example | |
754 | |
755 There was discussion in Octave of having these even prior to @sc{Matlab}, | |
756 and the decision was made not to have these in Octave at the time for | |
6900 | 757 compatibility. The above written with sub-functions functions would be |
6612 | 758 |
759 @example | |
760 @group | |
761 function y = foo (x) | |
762 y = bar(x) | |
763 end | |
764 function y = bar (x) | |
765 y = @dots{}; | |
766 end | |
767 @end group | |
768 @end example | |
769 | |
770 Now that @sc{Matlab} has recently introduced nested functions, Octave will | |
6900 | 771 probably have them soon as well. Until then nested functions in Octave |
6612 | 772 are treated as sub-functions with the same scoping rules as |
773 sub-functions. | |
774 | |
775 The authors of Octave consider the nested function scoping rules of | |
776 Matlab to be more problems than they are worth as they introduce | |
777 diffiult to find bugs as inadvertantly modifying a variable in a | |
778 nested function that is also used in the parent is particularly easy. | |
779 | |
780 @item Differences in core syntax | |
781 There a few core @sc{Matlab} syntaxes that are not accepted by Octave, | |
782 these being | |
783 | |
784 @itemize @bullet | |
2866 | 785 @item |
6612 | 786 Some limitations on the use of function handles. The major difference is |
6879 | 787 related to nested function scoping rules (as above) and their use with |
6612 | 788 function handles. |
2866 | 789 |
790 @item | |
6612 | 791 Some limitations of variable argument lists on the LHS of an expression, |
792 though the most common types are accepted. | |
793 | |
2866 | 794 @item |
8128 | 795 @sc{Matlab} classdef object oriented programming is not yet supportted, |
796 though work is underway and when development more on to Octave 3.3 this | |
797 will be included in teh development tree. | |
6612 | 798 @end itemize |
799 | |
800 @item Differences in core functions | |
801 A large number of the @sc{Matlab} core functions (ie those that are in | |
802 the core and not a toolbox) are implemented, and certainly all of the | |
803 commonly used ones. There are a few functions that aren't implemented, | |
6879 | 804 for example @code{condest} or to do with specific missing Octave functionality |
6612 | 805 (gui, dll, java, activex, dde, web, and serial functions). Some of the |
806 core functions have limitations that aren't in the @sc{Matlab} | |
6900 | 807 version. For example the @code{sprandn} function can not force a |
6735 | 808 particular condition number for the matrix like @sc{Matlab} can. |
6612 | 809 |
810 @item Just-In-Time compiler | |
811 @sc{Matlab} includes a "Just-In-Time" compiler. This compiler allows the | |
812 acceleration of for-loops in @sc{Matlab} to almost native performance with | |
813 certain restrictions. The JIT must know the return type of all functions | |
814 called in the loops and so you can't include user functions in the loop | |
6900 | 815 of JIT optimized loops. Octave doesn't have a JIT and so to some might |
816 seem slower than @sc{Matlab}. For this reason you must vectorize your code as | |
817 much as possible. The MathWorks themselves have a good document | |
818 discussing vectorization at | |
6612 | 819 @url{http://www.mathworks.com/support/tech-notes/1100/1109.html}. |
820 | |
821 @item Compiler | |
822 On a related point, there is no Octave compiler, and so you can't | |
823 convert your Octave code into a binary for additional speed or | |
6900 | 824 distribution. There is an example of how to do this at |
6612 | 825 @url{http://www.stud.tu-ilmenau.de/~rueckn/}, but this is a very early |
826 example code and would need lots of work to complete it. | |
827 | |
828 @item Graphic Handles | |
829 Up to Octave 2.9.9 there was no support for graphic handles in Octave | |
8128 | 830 itself. In the 3.2.N versions of Octave the support for graphics |
831 handles is converging towards full compatibility. The @code{patch} | |
832 function is currently limited to 2-D patches, due to an underlying | |
833 limitation in gnuplot. | |
6612 | 834 |
835 @item GUI | |
6900 | 836 There are no @sc{Matlab} compatible GUI functions. There are a number of |
837 bindings from Octave to Tcl/Tk, Vtk and zenity included in the | |
838 Octave Forge project (@url{http://octave.sourceforge.net}) for example | |
6612 | 839 that can be used for a GUI, but these are not @sc{Matlab} |
7116 | 840 compatible. Work on a matlab compatible GUI is in an alpha stage in the |
6879 | 841 JHandles package (@url{http://octave.sourceforge.net/jhandles/index.html}). |
842 This might be an issue if you intend to exchange Octave code with | |
843 @sc{Matlab} users. | |
6612 | 844 |
845 @item Simulink | |
846 Octave itself includes no Simulink support. Typically the simulink | |
847 models lag research and are less flexible, so shouldn't really be used | |
6900 | 848 in a research environment. However, some @sc{Matlab} users that try to |
849 use Octave complain about this lack. There is a similar package to | |
850 simulink for the Octave and R projects available at | |
851 @url{http://www.scicraft.org/} | |
6612 | 852 |
853 @item Mex-Files | |
854 Octave includes an API to the matlab MEX interface. However, as MEX is | |
6900 | 855 an API to the internals of @sc{Matlab} and the internals of Octave |
856 differ from @sc{Matlab}, there is necessarily a manipulation of the data | |
857 to convert from a MEX interface to the Octave equivalent. This is | |
858 notable for all complex matrices, where @sc{Matlab} stores complex | |
859 arrays as real and imaginary parts, whereas Octave respects the C99/C++ | |
860 standards of co-locating the real/imag parts in memory. Also due to the | |
861 way @sc{Matlab} allows access to the arrays passed through a pointer, | |
862 the MEX interface might require copies of arrays (even non complex | |
8128 | 863 ones). |
6612 | 864 |
865 @item Block comments | |
8128 | 866 Block comments denoted by "%@{" and "%@}" markers are supported by |
867 Octave with some limitations. The major limitation is that block | |
8292 | 868 comments are not supported within [] or @{@}. |
6612 | 869 |
870 @item Mat-File format | |
871 There are some differences in the mat v5 file format accepted by | |
872 Octave. @sc{Matlab} recently introduced the "-V7.3" save option which is | |
6900 | 873 an HDF5 format which is particularly useful for 64-bit platforms where |
6612 | 874 the standard matlab format can not correctly save variables.. Octave |
6900 | 875 accepts HDF5 files, but is not yet compatible with the "-v7.3" versions |
6612 | 876 produced by @sc{Matlab}. |
877 | |
8128 | 878 Although Octave can load inline abd function handles saved by |
879 @sc{Matlab}, it can not yet save them. | |
6612 | 880 |
881 Finally, Some multi-byte unicode characters aren't yet treated in | |
882 mat-files. | |
883 | |
884 @item Profiler | |
885 Octave doesn't have a profiler. Though there is a patch for a flat | |
886 profiler, that might become a real profiler sometime in the future. see | |
887 the thread | |
888 | |
889 @url{http://www.cae.wisc.edu/pipermail/octave-maintainers/2007-January/001685.html} | |
890 | |
891 for more details | |
892 | |
893 @item Toolboxes | |
894 Octave is a community project and so the toolboxes that exist are | |
6900 | 895 donated by those interested in them through the Octave Forge website |
6612 | 896 (@url{http://octave.sourceforge.net}). These might be lacking in certain |
897 functionality relative to the @sc{Matlab} toolboxes, and might not | |
898 exactly duplicate the matlab functionality or interface. | |
899 | |
900 @item Short-circuit & and | operators | |
6900 | 901 The @code{&} and @code{|} operators in @sc{Matlab} short-circuit when |
902 included in an if statemant and not otherwise. In Octave only the | |
903 @code{&&} and @code{||} short circuit. Note that this means that | |
6612 | 904 |
905 @example | |
906 @group | |
907 if (a | b) | |
908 @dots{} | |
909 end | |
910 @end group | |
911 @end example | |
912 | |
913 and | |
914 | |
915 @example | |
916 @group | |
917 t = a | b; | |
918 if t | |
919 @dots{} | |
920 end | |
921 @end group | |
922 @end example | |
923 | |
6900 | 924 @noindent |
6612 | 925 are different in @sc{Matlab}. This is really a @sc{Matlab} bug, but |
926 there is too much code out there that relies on this behavior to change | |
927 it. Prefer the || and && operators in if statements if possible. | |
2866 | 928 |
6612 | 929 Note that the difference is also significant when either argument is a |
930 function with side effects or if the first argument is a scalar and the | |
931 second argument is an empty matrix. For example, note the difference | |
932 between | |
933 | |
934 @example | |
935 @group | |
936 t = 1 | []; ## results in [], so... | |
937 if (t) 1, end ## in if ([]), this is false. | |
938 @end group | |
939 @end example | |
940 | |
941 and | |
942 | |
943 @example | |
944 if (1 | []) 1, end ## short circuits so condition is true. | |
945 @end example | |
946 | |
947 Another case that is documented in the @sc{Matlab} manuals is that | |
948 | |
949 @example | |
950 @group | |
951 t = [1, 1] | [1, 2, 3]; ## error | |
952 if ([1, 1] | [1, 2, 3]) 1, end ## OK | |
953 @end group | |
954 @end example | |
955 | |
956 Also @sc{Matlab} requires the operands of && and || to be scalar values but | |
957 Octave does not (it just applies the rule that for an operand to be | |
958 considered true, every element of the object must be nonzero or | |
959 logically true). | |
960 | |
961 Finally, note the inconsistence of thinking of the condition of an if | |
962 statement as being equivalent to @code{all(X(:))} when @var{X} is a | |
963 matrix. This is true for all cases EXCEPT empty matrices: | |
964 | |
965 @example | |
966 @group | |
967 if ([0, 1]) == if (all ([0, 1])) ==> i.e., condition is false. | |
968 if ([1, 1]) == if (all ([1, 1])) ==> i.e., condition is true. | |
969 @end group | |
970 @end example | |
971 | |
972 However, | |
973 | |
974 @example | |
975 if ([]) != if (all ([])) | |
976 @end example | |
977 | |
6900 | 978 because @code{samp ([]) == 1} (because, despite the name, it is really |
6612 | 979 returning true if none of the elements of the matrix are zero, and since |
980 there are no elements, well, none of them are zero). But, somewhere | |
981 along the line, someone decided that if @code{([])} should be false. | |
982 Mathworks probably thought it just looks wrong to have @code{[]} be true | |
983 in this context even if you can use logical gymnastics to convince | |
984 yourself that "all" the elements of a matrix that doesn't actually have | |
985 any elements are nonzero. Octave however duplicates this behavior for if | |
986 statements containing empty matrices. | |
987 | |
8292 | 988 @item Solvers for singular, under- and over-determined matrices |
989 | |
990 Matlab's solvers as used by the operators mldivide (\) and mrdivide (/), | |
991 use a different approach than Octave's in the case of singular, under-, | |
992 or over-determined matrices. In the case of a singular matrix, Matlab | |
993 returns the result given by the LU decomposition, even though the underlying | |
994 solver has flagged the result as erroneous. Octave has made the choice | |
995 of falling back to a minimum norm solution of matrices that have been | |
996 flagged as singular which arguably is a better result for these cases. | |
997 | |
998 In the case of under- or over-determined matrices, Octave continues to | |
999 use a minimum norm solution, whereas Matlab uses an approach that is | |
1000 equivalent to | |
1001 | |
1002 @example | |
1003 @group | |
1004 function x = mldivide (A, b) | |
1005 [Q, R, E] = qr(A); | |
1006 x = [A \ b, E(:, 1:m) * (R(:, 1:m) \ (Q' * b))] | |
1007 end | |
1008 @end group | |
1009 @end example | |
1010 | |
1011 @noindent | |
1012 While this approach is certainly faster and uses less memory than | |
1013 Octave's minimum norm approach, this approach seems to be inferior in | |
1014 other ways. | |
1015 | |
1016 A numerical question arises: how big can the null space component become, | |
1017 relative to the minimum-norm solution? Can it be nicely bounded, or can it be | |
1018 arbitrarily big? Consider this example: | |
1019 | |
1020 @example | |
1021 @group | |
1022 m = 10; | |
1023 n = 10000; | |
1024 A = ones(m, n) + 1e-6 * randn(m,n); | |
1025 b = ones(m, 1) + 1e-6 * randn(m,1); | |
1026 norm(A \ b) | |
1027 @end group | |
1028 @end example | |
1029 | |
1030 @noindent | |
1031 while Octave's minimum-norm values are around 3e-2, Matlab's results | |
1032 are 50-times larger. For another issue, try this code: | |
1033 | |
1034 @example | |
1035 @group | |
1036 m = 5; | |
1037 n = 100; | |
1038 j = floor(m * rand(1, n)) + 1; | |
1039 b = ones(m, 1); | |
1040 A = zeros(m, n); | |
1041 A(sub2ind(size(A),j,1:n)) = 1; | |
1042 x = A \ b; | |
1043 [dummy,p] = sort(rand(1,n)); | |
1044 y = A(:,p)\b; | |
1045 norm(x(p)-y) | |
1046 @end group | |
1047 @end example | |
1048 | |
1049 @noindent | |
1050 It shows that unlike in Octave, mldivide in Matlab is not invariant | |
1051 with respect to column permutations. If there are multiple columns of | |
1052 the same norm, permuting columns of the matrix gets you different | |
1053 result than permuting the solution vector. This will surprise many | |
1054 users. | |
1055 | |
1056 Since the mldivide (\) and mrdivide (/) operators are often part of a more | |
1057 complex expression, where there is no room to react to warnings or flags, it | |
1058 should prefer intelligence (robustness) to speed, and so the Octave developers | |
1059 are firmly of the opinion that Octave's approach for singular, under- and | |
1060 over-determined matrices is a better choice that Matlab's | |
1061 | |
6612 | 1062 @item Octave extensions |
1063 The extensions in Octave over @sc{Matlab} syntax are | |
1064 very useful, but might cause issues when sharing with @sc{Matlab} users. | |
1065 A list of the major extensions that should be avoided to be compatible | |
1066 with @sc{Matlab} are | |
1067 | |
1068 @itemize @bullet | |
1069 @item | |
6900 | 1070 Comments in octave can be marked with @samp{#}. This allows POSIX |
1071 systems to have the first line as @samp{#! octave -q} and mark the script | |
6653 | 1072 itself executable. @sc{Matlab} doesn't have this feature due to the |
6900 | 1073 absence of comments starting with @samp{#}". |
2866 | 1074 |
6612 | 1075 @item |
1076 Code blocks like if, for, while, etc can be terminated with block | |
1077 specific terminations like "endif". @sc{Matlab} doesn't have this and | |
1078 all blocks must be terminated with "end" | |
1079 | |
1080 @item | |
1081 Octave has a lisp like unwind_protect block that allows blocks of | |
1082 code that terminate in an error to ensure that the variables that | |
1083 are touched are restored. You can do something similar with | |
6900 | 1084 @code{try}/@code{catch} combined with @samp{rethrow (lasterror ())} in |
1085 @sc{Matlab}, however rethrow and lasterror are only available in Octave 2.9.10 and later. | |
6612 | 1086 |
6900 | 1087 Note that using @code{try}/@code{catch} combined with @samp{rethrow |
8325
b93ac0586e4b
spelling corrections
Brian Gough<bjg@network-theory.co.uk>
parents:
8292
diff
changeset
|
1088 (lasterror ())} can not guarantee that global variables will be |
6900 | 1089 correctly reset, as it won't catch user interrupts with Ctrl-C. For |
1090 example | |
6612 | 1091 |
1092 @example | |
1093 @group | |
1094 global a | |
1095 a = 1; | |
1096 try | |
1097 _a = a; | |
1098 a = 2 | |
1099 while true | |
1100 end | |
1101 catch | |
1102 fprintf ('caught interrupt\n'); | |
1103 a = _a; | |
1104 rethrow (lasterror()); | |
1105 end | |
1106 @end group | |
1107 @end example | |
1108 | |
1109 @noindent | |
1110 compared to | |
1111 | |
1112 @example | |
1113 @group | |
1114 global a | |
1115 a = 1; | |
1116 unwind_protect | |
1117 _a = a; | |
1118 a = 2 | |
1119 while true | |
1120 end | |
1121 unwind_protect_cleanup | |
1122 fprintf ('caught interrupt\n'); | |
1123 a = _a; | |
1124 end | |
1125 @end group | |
1126 @end example | |
1127 | |
1128 Typing Ctrl-C in the first case returns the user directly to the | |
6879 | 1129 prompt, and the variable "a" is not reset to the saved value. In the |
6900 | 1130 second case the variable "a" is reset correctly. Therefore @sc{Matlab} |
6612 | 1131 gives no save way of temporarily changing global variables. |
1132 | |
1133 @item | |
1134 Indexing can be applied to all objects in Octave and not just | |
1135 variable. Therefore @code{sin(x)(1:10);} for example is perfectly valid | |
1136 in Octave but not @sc{Matlab}. To do the same in @sc{Matlab} you must do | |
1137 @code{y = sin(x); y = y([1:10]);} | |
1138 | |
1139 @item | |
6900 | 1140 Octave has the operators "++", "--", "-=", "+=", "*=", etc. As |
6612 | 1141 @sc{Matlab} doesn't, if you are sharing code these should be avoided. |
1142 | |
1143 @item | |
6900 | 1144 Character strings in Octave can be denoted with double or single |
1145 quotes. There is a subtle difference between the two in that escaped | |
1146 characters like @code{\n} (newline), @code{\t} (tab), etc are | |
1147 interpreted in double quoted strings but not single quoted strings. This | |
1148 difference is important on Windows platforms where the "\" character is | |
1149 used in path names, and so single quoted strings should be used in | |
1150 paths. @sc{Matlab} doesn't have double quoted strings and so they should | |
1151 be avoided if the code will be transfered to a @sc{Matlab} user. | |
6612 | 1152 @end itemize |
1153 | |
1154 @end itemize | |
2866 | 1155 |
4830 | 1156 @node Index |
2866 | 1157 @appendix Concept Index |
1158 | |
1159 @printindex cp | |
1160 | |
1161 @page | |
1162 @contents | |
1163 @bye |