Mercurial > octave-nkf
comparison doc/faq/Octave-FAQ.texi @ 6900:e2d560e5a58d
[project @ 2007-09-14 17:00:15 by jwe]
author | jwe |
---|---|
date | Fri, 14 Sep 2007 17:00:15 +0000 |
parents | 28f3be713c1d |
children | fd42779a8428 |
comparison
equal
deleted
inserted
replaced
6899:110c5782fe3b | 6900:e2d560e5a58d |
---|---|
8 * Octave-FAQ: (Octave-FAQ). Frequently asked questions about Octave | 8 * Octave-FAQ: (Octave-FAQ). Frequently asked questions about Octave |
9 @end direntry | 9 @end direntry |
10 @titlepage | 10 @titlepage |
11 @title Octave FAQ | 11 @title Octave FAQ |
12 @subtitle Frequently asked questions about Octave | 12 @subtitle Frequently asked questions about Octave |
13 @subtitle June, 2007 | 13 @subtitle September 2007 |
14 @sp 1 | 14 @sp 1 |
15 @author John W. Eaton | 15 @author John W. Eaton and David Bateman |
16 @page | 16 @page |
17 @end titlepage | 17 @end titlepage |
18 | 18 |
19 @ifnottex | 19 @ifnottex |
20 @node Top | 20 @node Top |
589 @itemize @bullet | 589 @itemize @bullet |
590 @item | 590 @item |
591 Octave takes a long time to find symbols. | 591 Octave takes a long time to find symbols. |
592 | 592 |
593 Octave uses the @code{genpath} function to recursively add directories | 593 Octave uses the @code{genpath} function to recursively add directories |
594 to the list of directories searched for function files. Check the list | 594 to the list of directories searched for function files. Check the list |
595 of directories with the @code{path} command. If the path list is very | 595 of directories with the @code{path} command. If the path list is very |
596 long check your use of the @code{genpath} function. | 596 long check your use of the @code{genpath} function. |
597 | 597 |
598 @item | 598 @item |
599 When plotting Octave occasionally gives me errors like ``gnuplot> 9 0.735604 | 599 When plotting Octave occasionally gives me errors like @samp{gnuplot> 9 0.735604 |
600 line 26317: invalid command'' | 600 line 26317: invalid command}. |
601 | 601 |
602 There is a known bug in gnuplot 4.2 that can cause an off by one error | 602 There is a known bug in gnuplot 4.2 that can cause an off by one error |
603 while piping data to gnuplot. The relevant gnuplot bug report can be | 603 while piping data to gnuplot. The relevant gnuplot bug report can be |
604 found at @url{http://sourceforge.net/tracker/index.php?func=detail&aid=1716556&group_id=2055&atid=102055} | 604 found at @url{http://sourceforge.net/tracker/index.php?func=detail&aid=1716556&group_id=2055&atid=102055} |
605 | 605 |
618 @cindex Tips and tricks | 618 @cindex Tips and tricks |
619 @cindex How do I @dots{} ? | 619 @cindex How do I @dots{} ? |
620 | 620 |
621 @node How do I set the number of displayed decimals? | 621 @node How do I set the number of displayed decimals? |
622 @section How do I set the number of displayed decimals? | 622 @section How do I set the number of displayed decimals? |
623 | |
624 | 623 |
625 @example | 624 @example |
626 @group | 625 @group |
627 octave:1> format long | 626 octave:1> format long |
628 octave:2> pi | 627 octave:2> pi |
645 Octave. Is there anything I should watch out for?'' | 644 Octave. Is there anything I should watch out for?'' |
646 | 645 |
647 or alternatively | 646 or alternatively |
648 | 647 |
649 ``I wrote some code in Octave, and want to share it with @sc{Matlab} | 648 ``I wrote some code in Octave, and want to share it with @sc{Matlab} |
650 users. Is there anything I should watch out for?'' | 649 users. Is there anything I should watch out for?'' |
651 | 650 |
652 which is not quite the same thing. There are still a number of | 651 which is not quite the same thing. There are still a number of |
653 differences between Octave and @sc{Matlab}, however in general | 652 differences between Octave and @sc{Matlab}, however in general |
654 differences between the two are considered as bugs. Octave might | 653 differences between the two are considered as bugs. Octave might |
655 consider that the bug is in @sc{Matlab} and do nothing about it, but | 654 consider that the bug is in @sc{Matlab} and do nothing about it, but |
656 generally functionality is almost identical. If you find a difference | 655 generally functionality is almost identical. If you find a difference |
657 between Octave behavior and @sc{Matlab}, then you should send a | 656 between Octave behavior and @sc{Matlab}, then you should send a |
673 The major differences between Octave 2.9.N and @sc{Matlab} R2007a are: | 672 The major differences between Octave 2.9.N and @sc{Matlab} R2007a are: |
674 | 673 |
675 @itemize @bullet | 674 @itemize @bullet |
676 @item Nested Functions | 675 @item Nested Functions |
677 | 676 |
678 Octave doesn't yet have nested functions. That if | 677 Octave doesn't yet have nested functions. That is |
679 | 678 |
680 @example | 679 @example |
681 @group | 680 @group |
682 function y = foo (x) | 681 function y = foo (x) |
683 y = bar(x) | 682 y = bar(x) |
684 function y = bar (x) | 683 function y = bar (x) |
685 y = @dots{}; | 684 y = @dots{}; |
686 end | 685 end |
687 end | 686 end |
688 @end group | 687 @end group |
689 @end example | 688 @end example |
690 | 689 |
691 There was discussion in Octave of having these even prior to @sc{Matlab}, | 690 There was discussion in Octave of having these even prior to @sc{Matlab}, |
692 and the decision was made not to have these in Octave at the time for | 691 and the decision was made not to have these in Octave at the time for |
693 compatibility. The above written with sub-functions functions would be | 692 compatibility. The above written with sub-functions functions would be |
694 | 693 |
695 @example | 694 @example |
696 @group | 695 @group |
697 function y = foo (x) | 696 function y = foo (x) |
698 y = bar(x) | 697 y = bar(x) |
702 end | 701 end |
703 @end group | 702 @end group |
704 @end example | 703 @end example |
705 | 704 |
706 Now that @sc{Matlab} has recently introduced nested functions, Octave will | 705 Now that @sc{Matlab} has recently introduced nested functions, Octave will |
707 probably have them soon as well. Till then nested functions in Octave | 706 probably have them soon as well. Until then nested functions in Octave |
708 are treated as sub-functions with the same scoping rules as | 707 are treated as sub-functions with the same scoping rules as |
709 sub-functions. | 708 sub-functions. |
710 | 709 |
711 The authors of Octave consider the nested function scoping rules of | 710 The authors of Octave consider the nested function scoping rules of |
712 Matlab to be more problems than they are worth as they introduce | 711 Matlab to be more problems than they are worth as they introduce |
713 diffiult to find bugs as inadvertantly modifying a variable in a | 712 diffiult to find bugs as inadvertantly modifying a variable in a |
714 nested function that is also used in the parent is particularly easy. | 713 nested function that is also used in the parent is particularly easy. |
715 | 714 |
716 @item Differences in core syntax | 715 @item Differences in core syntax |
717 | |
718 There a few core @sc{Matlab} syntaxes that are not accepted by Octave, | 716 There a few core @sc{Matlab} syntaxes that are not accepted by Octave, |
719 these being | 717 these being |
720 | 718 |
721 @itemize @bullet | 719 @itemize @bullet |
722 @item | 720 @item |
734 remove this restriction in the future. | 732 remove this restriction in the future. |
735 | 733 |
736 @item | 734 @item |
737 @sc{Matlab} private directories are not treated, though as for classes, | 735 @sc{Matlab} private directories are not treated, though as for classes, |
738 this will change in the near future. This restriction can be alleviated by | 736 this will change in the near future. This restriction can be alleviated by |
739 using addpath on the private directories, but this makes the private | 737 using @code{addpath} on the private directories, but this makes the |
740 directories visible in the global scope. | 738 private directories visible in the global scope. |
741 @end itemize | 739 @end itemize |
742 | 740 |
743 @item Differences in core functions | 741 @item Differences in core functions |
744 | |
745 A large number of the @sc{Matlab} core functions (ie those that are in | 742 A large number of the @sc{Matlab} core functions (ie those that are in |
746 the core and not a toolbox) are implemented, and certainly all of the | 743 the core and not a toolbox) are implemented, and certainly all of the |
747 commonly used ones. There are a few functions that aren't implemented, | 744 commonly used ones. There are a few functions that aren't implemented, |
748 for example @code{condest} or to do with specific missing Octave functionality | 745 for example @code{condest} or to do with specific missing Octave functionality |
749 (gui, dll, java, activex, dde, web, and serial functions). Some of the | 746 (gui, dll, java, activex, dde, web, and serial functions). Some of the |
750 core functions have limitations that aren't in the @sc{Matlab} | 747 core functions have limitations that aren't in the @sc{Matlab} |
751 version. For example the @code{sprandn} function can not force a | 748 version. For example the @code{sprandn} function can not force a |
752 particular condition number for the matrix like @sc{Matlab} can. | 749 particular condition number for the matrix like @sc{Matlab} can. |
753 | 750 |
754 @item Just-In-Time compiler | 751 @item Just-In-Time compiler |
755 | |
756 @sc{Matlab} includes a "Just-In-Time" compiler. This compiler allows the | 752 @sc{Matlab} includes a "Just-In-Time" compiler. This compiler allows the |
757 acceleration of for-loops in @sc{Matlab} to almost native performance with | 753 acceleration of for-loops in @sc{Matlab} to almost native performance with |
758 certain restrictions. The JIT must know the return type of all functions | 754 certain restrictions. The JIT must know the return type of all functions |
759 called in the loops and so you can't include user functions in the loop | 755 called in the loops and so you can't include user functions in the loop |
760 of JIT optimized loops. Octave doesn't have a JIT and so to some might | 756 of JIT optimized loops. Octave doesn't have a JIT and so to some might |
761 seem slower than @sc{Matlab}. For this reason you must vectorize your code as | 757 seem slower than @sc{Matlab}. For this reason you must vectorize your code as |
762 much as possible. @sc{Matlab} themselves produces a good document discussing | 758 much as possible. The MathWorks themselves have a good document |
763 vectorization at | 759 discussing vectorization at |
764 @url{http://www.mathworks.com/support/tech-notes/1100/1109.html}. | 760 @url{http://www.mathworks.com/support/tech-notes/1100/1109.html}. |
765 | 761 |
766 @item Compiler | 762 @item Compiler |
767 | |
768 On a related point, there is no Octave compiler, and so you can't | 763 On a related point, there is no Octave compiler, and so you can't |
769 convert your Octave code into a binary for additional speed or | 764 convert your Octave code into a binary for additional speed or |
770 distribution. There is an example of how to do this at | 765 distribution. There is an example of how to do this at |
771 @url{http://www.stud.tu-ilmenau.de/~rueckn/}, but this is a very early | 766 @url{http://www.stud.tu-ilmenau.de/~rueckn/}, but this is a very early |
772 example code and would need lots of work to complete it. | 767 example code and would need lots of work to complete it. |
773 | 768 |
774 @item Graphic Handles | 769 @item Graphic Handles |
775 | |
776 Up to Octave 2.9.9 there was no support for graphic handles in Octave | 770 Up to Octave 2.9.9 there was no support for graphic handles in Octave |
777 itself. There is in Octave 2.9.10 and later, and so the graphics between | 771 itself. There is in Octave 2.9.10 and later, and so the graphics between |
778 Octave and @sc{Matlab} are currently in the process of converging to a | 772 Octave and @sc{Matlab} are currently in the process of converging to a |
779 common interface. Note that the basic graphic handle stuff is in place | 773 common interface. Note that the basic graphic handle stuff is in place |
780 since 2.9.10, but not certain graphics objects like "barseries", | 774 since 2.9.10, but not certain graphics objects like "barseries", |
781 etc. The @code{patch} function is currently limited to 2-D patches, due | 775 etc. The @code{patch} function is currently limited to 2-D patches, due |
782 to an underlying limitation in gnuplot/ | 776 to an underlying limitation in gnuplot. |
783 | 777 |
784 @item GUI | 778 @item GUI |
785 | 779 There are no @sc{Matlab} compatible GUI functions. There are a number of |
786 There is no @sc{Matlab} compatible GUI functions. There are a number of | 780 bindings from Octave to Tcl/Tk, Vtk and zenity included in the |
787 bindings from Octave to tcl/tk, vtk and zenity included in the | 781 Octave Forge project (@url{http://octave.sourceforge.net}) for example |
788 octave-forge project (@url{http://octave.sourceforge.net}) for example | |
789 that can be used for a GUI, but these are not @sc{Matlab} | 782 that can be used for a GUI, but these are not @sc{Matlab} |
790 compatible. Work on a matlab compatiable GUI is in an alpha stage in the | 783 compatible. Work on a matlab compatiable GUI is in an alpha stage in the |
791 JHandles package (@url{http://octave.sourceforge.net/jhandles/index.html}). | 784 JHandles package (@url{http://octave.sourceforge.net/jhandles/index.html}). |
792 This might be an issue if you intend to exchange Octave code with | 785 This might be an issue if you intend to exchange Octave code with |
793 @sc{Matlab} users. | 786 @sc{Matlab} users. |
794 | 787 |
795 @item Simulink | 788 @item Simulink |
796 | |
797 Octave itself includes no Simulink support. Typically the simulink | 789 Octave itself includes no Simulink support. Typically the simulink |
798 models lag research and are less flexible, so shouldn't really be used | 790 models lag research and are less flexible, so shouldn't really be used |
799 in a research environment. However, some @sc{Matlab} users that try to use | 791 in a research environment. However, some @sc{Matlab} users that try to |
800 Octave complain about this lack. There is a similar package to simulink | 792 use Octave complain about this lack. There is a similar package to |
801 for the Octave and R projects available at @url{http://www.scicraft.org/} | 793 simulink for the Octave and R projects available at |
794 @url{http://www.scicraft.org/} | |
802 | 795 |
803 @item Mex-Files | 796 @item Mex-Files |
804 | |
805 Octave includes an API to the matlab MEX interface. However, as MEX is | 797 Octave includes an API to the matlab MEX interface. However, as MEX is |
806 an API to the internals of @sc{Matlab} and the internals of Octave differ to | 798 an API to the internals of @sc{Matlab} and the internals of Octave |
807 @sc{Matlab}, there is necessarily a manipulation of the data to convert from | 799 differ from @sc{Matlab}, there is necessarily a manipulation of the data |
808 a MEX interface to the Octave equivalent. This is notable for all | 800 to convert from a MEX interface to the Octave equivalent. This is |
809 complex matrices, where matlab stores complex arrays as real and | 801 notable for all complex matrices, where @sc{Matlab} stores complex |
810 imaginary parts, whereas Octave respects the C99/C++ standards of | 802 arrays as real and imaginary parts, whereas Octave respects the C99/C++ |
811 co-locating the real/imag parts in memory. Also due to the way @sc{Matlab} | 803 standards of co-locating the real/imag parts in memory. Also due to the |
812 allows access to the arrays passed through a pointer, the MEX interface | 804 way @sc{Matlab} allows access to the arrays passed through a pointer, |
813 might require that copies of arrays (even non complex ones). There were | 805 the MEX interface might require copies of arrays (even non complex |
814 some serious memory leaks in the MEX API in Octave up to version 2.9.9, | 806 ones). There were some serious memory leaks in the MEX API in Octave up |
815 and version 2.9.10 or later should be used if posible. | 807 to version 2.9.9, and version 2.9.10 or later should be used if posible. |
816 | 808 |
817 @item Block comments | 809 @item Block comments |
818 | |
819 @sc{Matlab} recently included the possibility to have block comments. With | 810 @sc{Matlab} recently included the possibility to have block comments. With |
820 the "%@{" and "%@}" markers. Octave doesn't yet have block comments, but | 811 the "%@{" and "%@}" markers. Octave doesn't yet have block comments, but |
821 might in the future. | 812 might in the future. |
822 | 813 |
823 @item Mat-File format | 814 @item Mat-File format |
824 | |
825 There are some differences in the mat v5 file format accepted by | 815 There are some differences in the mat v5 file format accepted by |
826 Octave. @sc{Matlab} recently introduced the "-V7.3" save option which is | 816 Octave. @sc{Matlab} recently introduced the "-V7.3" save option which is |
827 an hdf5 format which is particularly useful for 64-bit platforms where | 817 an HDF5 format which is particularly useful for 64-bit platforms where |
828 the standard matlab format can not correctly save variables.. Octave | 818 the standard matlab format can not correctly save variables.. Octave |
829 accepts hdf5 files, but is not yet compatible with the "-v7.3" versions | 819 accepts HDF5 files, but is not yet compatible with the "-v7.3" versions |
830 produced by @sc{Matlab}. | 820 produced by @sc{Matlab}. |
831 | 821 |
832 Up to version 2.9.10, Octave can't load/save the inline or function | 822 Up to version 2.9.10, Octave can't load/save the inline or function |
833 handles saved in mat-files by @sc{Matlab} (though can in its own | 823 handles saved in mat-files by @sc{Matlab} (though can in its own |
834 format). In 2.9.11 and later Octave can load inline and function handles | 824 format). In 2.9.11 and later Octave can load inline and function handles |
836 | 826 |
837 Finally, Some multi-byte unicode characters aren't yet treated in | 827 Finally, Some multi-byte unicode characters aren't yet treated in |
838 mat-files. | 828 mat-files. |
839 | 829 |
840 @item Profiler | 830 @item Profiler |
841 | |
842 Octave doesn't have a profiler. Though there is a patch for a flat | 831 Octave doesn't have a profiler. Though there is a patch for a flat |
843 profiler, that might become a real profiler sometime in the future. see | 832 profiler, that might become a real profiler sometime in the future. see |
844 the thread | 833 the thread |
845 | 834 |
846 @url{http://www.cae.wisc.edu/pipermail/octave-maintainers/2007-January/001685.html} | 835 @url{http://www.cae.wisc.edu/pipermail/octave-maintainers/2007-January/001685.html} |
847 | 836 |
848 for more details | 837 for more details |
849 | 838 |
850 @item Toolboxes | 839 @item Toolboxes |
851 | |
852 Octave is a community project and so the toolboxes that exist are | 840 Octave is a community project and so the toolboxes that exist are |
853 donated by those interested in them through the octave-forge website | 841 donated by those interested in them through the Octave Forge website |
854 (@url{http://octave.sourceforge.net}). These might be lacking in certain | 842 (@url{http://octave.sourceforge.net}). These might be lacking in certain |
855 functionality relative to the @sc{Matlab} toolboxes, and might not | 843 functionality relative to the @sc{Matlab} toolboxes, and might not |
856 exactly duplicate the matlab functionality or interface. | 844 exactly duplicate the matlab functionality or interface. |
857 | 845 |
858 @item Short-circuit & and | operators | 846 @item Short-circuit & and | operators |
859 | 847 The @code{&} and @code{|} operators in @sc{Matlab} short-circuit when |
860 The & and | operators in @sc{Matlab} short-circuit when included in an if | 848 included in an if statemant and not otherwise. In Octave only the |
861 statemant and not otherwise. Whereas in Octave only the && and || | 849 @code{&&} and @code{||} short circuit. Note that this means that |
862 short circuit. This is due to the absence of && and || in @sc{Matlab} | |
863 till recently. Note that this means that | |
864 | 850 |
865 @example | 851 @example |
866 @group | 852 @group |
867 if (a | b) | 853 if (a | b) |
868 @dots{} | 854 @dots{} |
879 @dots{} | 865 @dots{} |
880 end | 866 end |
881 @end group | 867 @end group |
882 @end example | 868 @end example |
883 | 869 |
870 @noindent | |
884 are different in @sc{Matlab}. This is really a @sc{Matlab} bug, but | 871 are different in @sc{Matlab}. This is really a @sc{Matlab} bug, but |
885 there is too much code out there that relies on this behavior to change | 872 there is too much code out there that relies on this behavior to change |
886 it. Prefer the || and && operators in if statements if possible. | 873 it. Prefer the || and && operators in if statements if possible. |
887 | 874 |
888 Note that the difference is also significant when either argument is a | 875 Note that the difference is also significant when either argument is a |
932 | 919 |
933 @example | 920 @example |
934 if ([]) != if (all ([])) | 921 if ([]) != if (all ([])) |
935 @end example | 922 @end example |
936 | 923 |
937 because @code{all ([]) == 1} (because, despite the name, it is really | 924 because @code{samp ([]) == 1} (because, despite the name, it is really |
938 returning true if none of the elements of the matrix are zero, and since | 925 returning true if none of the elements of the matrix are zero, and since |
939 there are no elements, well, none of them are zero). But, somewhere | 926 there are no elements, well, none of them are zero). But, somewhere |
940 along the line, someone decided that if @code{([])} should be false. | 927 along the line, someone decided that if @code{([])} should be false. |
941 Mathworks probably thought it just looks wrong to have @code{[]} be true | 928 Mathworks probably thought it just looks wrong to have @code{[]} be true |
942 in this context even if you can use logical gymnastics to convince | 929 in this context even if you can use logical gymnastics to convince |
943 yourself that "all" the elements of a matrix that doesn't actually have | 930 yourself that "all" the elements of a matrix that doesn't actually have |
944 any elements are nonzero. Octave however duplicates this behavior for if | 931 any elements are nonzero. Octave however duplicates this behavior for if |
945 statements containing empty matrices. | 932 statements containing empty matrices. |
946 | 933 |
947 @item Octave extensions | 934 @item Octave extensions |
948 | |
949 The extensions in Octave over @sc{Matlab} syntax are | 935 The extensions in Octave over @sc{Matlab} syntax are |
950 very useful, but might cause issues when sharing with @sc{Matlab} users. | 936 very useful, but might cause issues when sharing with @sc{Matlab} users. |
951 A list of the major extensions that should be avoided to be compatible | 937 A list of the major extensions that should be avoided to be compatible |
952 with @sc{Matlab} are | 938 with @sc{Matlab} are |
953 | 939 |
954 @itemize @bullet | 940 @itemize @bullet |
955 @item | 941 @item |
956 Comments in octave can be marked with "#". This allows POSIX | 942 Comments in octave can be marked with @samp{#}. This allows POSIX |
957 systems to have the first line as "#! octave -q" and mark the script | 943 systems to have the first line as @samp{#! octave -q} and mark the script |
958 itself executable. @sc{Matlab} doesn't have this feature due to the | 944 itself executable. @sc{Matlab} doesn't have this feature due to the |
959 absence of comments starting with "#" | 945 absence of comments starting with @samp{#}". |
960 | 946 |
961 @item | 947 @item |
962 Code blocks like if, for, while, etc can be terminated with block | 948 Code blocks like if, for, while, etc can be terminated with block |
963 specific terminations like "endif". @sc{Matlab} doesn't have this and | 949 specific terminations like "endif". @sc{Matlab} doesn't have this and |
964 all blocks must be terminated with "end" | 950 all blocks must be terminated with "end" |
965 | 951 |
966 @item | 952 @item |
967 Octave has a lisp like unwind_protect block that allows blocks of | 953 Octave has a lisp like unwind_protect block that allows blocks of |
968 code that terminate in an error to ensure that the variables that | 954 code that terminate in an error to ensure that the variables that |
969 are touched are restored. You can do something similar with | 955 are touched are restored. You can do something similar with |
970 try/catch combined with rethrow(lasterror()) in @sc{Matlab}, however | 956 @code{try}/@code{catch} combined with @samp{rethrow (lasterror ())} in |
971 rethrow and lasterror are only available in Octave 2.9.10 and later. | 957 @sc{Matlab}, however rethrow and lasterror are only available in Octave 2.9.10 and later. |
972 | 958 |
973 Note that using try/catch combined with rethrow(lasterror()) can not | 959 Note that using @code{try}/@code{catch} combined with @samp{rethrow |
974 guarentee that global variables will be correctly reset, as it won't | 960 (lasterror ())} can not guarentee that global variables will be |
975 catch user interrupts with Ctrl-C. For example | 961 correctly reset, as it won't catch user interrupts with Ctrl-C. For |
962 example | |
976 | 963 |
977 @example | 964 @example |
978 @group | 965 @group |
979 global a | 966 global a |
980 a = 1; | 967 a = 1; |
1010 @end group | 997 @end group |
1011 @end example | 998 @end example |
1012 | 999 |
1013 Typing Ctrl-C in the first case returns the user directly to the | 1000 Typing Ctrl-C in the first case returns the user directly to the |
1014 prompt, and the variable "a" is not reset to the saved value. In the | 1001 prompt, and the variable "a" is not reset to the saved value. In the |
1015 second case the variable "a" is reset correctly. Therefore @sc{Matlab} | 1002 second case the variable "a" is reset correctly. Therefore @sc{Matlab} |
1016 gives no save way of temporarily changing global variables. | 1003 gives no save way of temporarily changing global variables. |
1017 | 1004 |
1018 @item | 1005 @item |
1019 Indexing can be applied to all objects in Octave and not just | 1006 Indexing can be applied to all objects in Octave and not just |
1020 variable. Therefore @code{sin(x)(1:10);} for example is perfectly valid | 1007 variable. Therefore @code{sin(x)(1:10);} for example is perfectly valid |
1021 in Octave but not @sc{Matlab}. To do the same in @sc{Matlab} you must do | 1008 in Octave but not @sc{Matlab}. To do the same in @sc{Matlab} you must do |
1022 @code{y = sin(x); y = y([1:10]);} | 1009 @code{y = sin(x); y = y([1:10]);} |
1023 | 1010 |
1024 @item | 1011 @item |
1025 Octave has the operators "++", "--", "-=", "+=", "*=", etc. As | 1012 Octave has the operators "++", "--", "-=", "+=", "*=", etc. As |
1026 @sc{Matlab} doesn't, if you are sharing code these should be avoided. | 1013 @sc{Matlab} doesn't, if you are sharing code these should be avoided. |
1027 | 1014 |
1028 @item | 1015 @item |
1029 Strings in Octave can be denoted with double or single quotes. There is | 1016 Character strings in Octave can be denoted with double or single |
1030 a subtle difference between the two in that escaped characters like \n, | 1017 quotes. There is a subtle difference between the two in that escaped |
1031 etc are interpreted in double quoted strings but not single quoted | 1018 characters like @code{\n} (newline), @code{\t} (tab), etc are |
1032 strings. This difference is important on Windows platforms where the "\" | 1019 interpreted in double quoted strings but not single quoted strings. This |
1033 character is used in path names, and so single quoted strings should be | 1020 difference is important on Windows platforms where the "\" character is |
1034 used in paths. @sc{Matlab} doesn't have double quoted strings and so | 1021 used in path names, and so single quoted strings should be used in |
1035 they should be avoided if the code will be transfered to a matlab user. | 1022 paths. @sc{Matlab} doesn't have double quoted strings and so they should |
1023 be avoided if the code will be transfered to a @sc{Matlab} user. | |
1036 @end itemize | 1024 @end itemize |
1037 | 1025 |
1038 @end itemize | 1026 @end itemize |
1039 | 1027 |
1040 @node Index | 1028 @node Index |