FAQ: Difference between revisions

1 byte added ,  27 January 2014
m
Line 823: Line 823:
Indexing can be applied to all objects in Octave and not just variables. Therefore {{Codeline|sin(x)(1:10)}} for example is perfectly valid in Octave but not Matlab. To do the same in Matlab you must do {{Codeline|y = sin(x); y = y([1:10]);}}
Indexing can be applied to all objects in Octave and not just variables. Therefore {{Codeline|sin(x)(1:10)}} for example is perfectly valid in Octave but not Matlab. To do the same in Matlab you must do {{Codeline|y = sin(x); y = y([1:10]);}}


Octave has the operators {{Codeline|++}}, {{Codeline|–}}, {{Codeline|-=}}, {{Codeline|+=}}, {{Codeline|*=}}, etc. As Matlab doesn't, if you are sharing code these should be avoided.
Octave has the operators {{Codeline|++}}, {{Codeline|–-}}, {{Codeline|-=}}, {{Codeline|+=}}, {{Codeline|*=}}, etc. As Matlab doesn't, if you are sharing code these should be avoided.


Character strings in Octave can be denoted with double or single quotes. There is a subtle difference between the two in that escaped characters like {{Codeline|\n}} (newline), {{Codeline|\t}} (tab), etc are interpreted in double quoted strings but not single quoted strings. This difference is important on Windows platforms where the {{Codeline|\}} character is used in path names, and so single quoted strings should be used in paths. Matlab doesn't have double quoted strings and so they should be avoided if the code will be transferred to a Matlab user.
Character strings in Octave can be denoted with double or single quotes. There is a subtle difference between the two in that escaped characters like {{Codeline|\n}} (newline), {{Codeline|\t}} (tab), etc are interpreted in double quoted strings but not single quoted strings. This difference is important on Windows platforms where the {{Codeline|\}} character is used in path names, and so single quoted strings should be used in paths. Matlab doesn't have double quoted strings and so they should be avoided if the code will be transferred to a Matlab user.