Warning, /frameworks/syntax-highlighting/autotests/input/test.octave is written in an unsupported language. File is not indexed.
0001 # This is test comment
0002 % this is another comment
0003 a = 3; b = 34;
0004
0005 function retval = avg (v)
0006 retval = 0;
0007 if (isvector (v))
0008 retval = sum (v) / length (v);
0009 else
0010 error ("avg: expecting vector argument");
0011 endif
0012 endfunction
0013
0014 if (rem (x, 2) == 0)
0015 printf ("x is even\n");
0016 else
0017 printf ("x is odd\n");
0018 endif
0019
0020 if (rem (x, 2) == 0)
0021 printf ("x is even\n");
0022 elseif (rem (x, 3) == 0)
0023 printf ("x is odd and divisible by 3\n");
0024 else
0025 printf ("x is odd\n");
0026 end
0027
0028 if (rem(x,2) == 0) x = 5; elseif (rem (x,3) == 0) x = 3; else x = 0; end
0029
0030 cd ..
0031
0032 while (i <= 10)
0033 fib (i) = fib (i-1) + fib (i-2);
0034 i++;
0035 endwhile
0036
0037 classdef polynomial2
0038 properties
0039 poly = 0;
0040 endproperties
0041
0042 methods
0043 function p = polynomial2 (a)
0044 if (nargin > 1)
0045 print_usage ();
0046 endif
0047
0048 if (nargin == 1)
0049 if (isa (a, "polynomial2"))
0050 p.poly = a.poly;
0051 elseif (isreal (a) && isvector (a))
0052 p.poly = a(:).'; # force row vector
0053 else
0054 error ("polynomial2: A must be a real vector");
0055 endif
0056 endif
0057 endfunction
0058
0059 function disp (p)
0060 a = p.poly;
0061 first = true;
0062 for i = 1 : length (a);
0063 if (a(i) != 0)
0064 if (first)
0065 first = false;
0066 elseif (a(i) > 0 || isnan (a(i)))
0067 printf (" +");
0068 endif
0069 if (a(i) < 0)
0070 printf (" -");
0071 endif
0072 if (i == 1)
0073 printf (" %.5g", abs (a(i)));
0074 elseif (abs (a(i)) != 1)
0075 printf (" %.5g *", abs (a(i)));
0076 endif
0077 if (i > 1)
0078 printf (" X");
0079 endif
0080 if (i > 2)
0081 printf (" ^ %d", i - 1);
0082 endif
0083 endif
0084 endfor
0085
0086 if (first)
0087 printf (" 0");
0088 endif
0089 printf ("\n");
0090 endfunction
0091 endmethods
0092 endclassdef