octave:2> a=17 a = 17 octave:3> b=3.1415; octave:4> x=linspace(0,10) x = Columns 1 through 7: 0.00000 0.10101 0.20202 0.30303 0.40404 0.50505 0.60606 Columns 8 through 14: 0.70707 0.80808 0.90909 1.01010 1.11111 1.21212 1.31313 Columns 15 through 21: 1.41414 1.51515 1.61616 1.71717 1.81818 1.91919 2.02020 Columns 22 through 28: 2.12121 2.22222 2.32323 2.42424 2.52525 2.62626 2.72727 Columns 29 through 35: 2.82828 2.92929 3.03030 3.13131 3.23232 3.33333 3.43434 Columns 36 through 42: 3.53535 3.63636 3.73737 3.83838 3.93939 4.04040 4.14141 Columns 43 through 49: 4.24242 4.34343 4.44444 4.54545 4.64646 4.74747 4.84848 Columns 50 through 56: 4.94949 5.05051 5.15152 5.25253 5.35354 5.45455 5.55556 Columns 57 through 63: 5.65657 5.75758 5.85859 5.95960 6.06061 6.16162 6.26263 Columns 64 through 70: 6.36364 6.46465 6.56566 6.66667 6.76768 6.86869 6.96970 Columns 71 through 77: 7.07071 7.17172 7.27273 7.37374 7.47475 7.57576 7.67677 Columns 78 through 84: 7.77778 7.87879 7.97980 8.08081 8.18182 8.28283 8.38384 Columns 85 through 91: 8.48485 8.58586 8.68687 8.78788 8.88889 8.98990 9.09091 Columns 92 through 98: 9.19192 9.29293 9.39394 9.49495 9.59596 9.69697 9.79798 Columns 99 and 100: 9.89899 10.00000 octave:5> x=linspace(0,10); octave:6> clc octave:7> x=linspace(0,10) x = Columns 1 through 7: 0.00000 0.10101 0.20202 0.30303 0.40404 0.50505 0.60606 Columns 8 through 14: 0.70707 0.80808 0.90909 1.01010 1.11111 1.21212 1.31313 Columns 15 through 21: 1.41414 1.51515 1.61616 1.71717 1.81818 1.91919 2.02020 Columns 22 through 28: 2.12121 2.22222 2.32323 2.42424 2.52525 2.62626 2.72727 Columns 29 through 35: 2.82828 2.92929 3.03030 3.13131 3.23232 3.33333 3.43434 Columns 36 through 42: 3.53535 3.63636 3.73737 3.83838 3.93939 4.04040 4.14141 Columns 43 through 49: 4.24242 4.34343 4.44444 4.54545 4.64646 4.74747 4.84848 Columns 50 through 56: 4.94949 5.05051 5.15152 5.25253 5.35354 5.45455 5.55556 Columns 57 through 63: 5.65657 5.75758 5.85859 5.95960 6.06061 6.16162 6.26263 Columns 64 through 70: 6.36364 6.46465 6.56566 6.66667 6.76768 6.86869 6.96970 Columns 71 through 77: 7.07071 7.17172 7.27273 7.37374 7.47475 7.57576 7.67677 Columns 78 through 84: 7.77778 7.87879 7.97980 8.08081 8.18182 8.28283 8.38384 Columns 85 through 91: 8.48485 8.58586 8.68687 8.78788 8.88889 8.98990 9.09091 Columns 92 through 98: 9.19192 9.29293 9.39394 9.49495 9.59596 9.69697 9.79798 Columns 99 and 100: 9.89899 10.00000 octave:8> clc octave:9> who Variables in the current scope: a ans b x octave:10> whos Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== a 1x1 8 double ans 1x26 26 char b 1x1 8 double x 1x100 800 double Total is 128 elements using 842 bytes octave:11> as error: 'as' undefined near line 11 column 1 octave:11> a a = 17 octave:12> pi ans = 3.1416 octave:13> p=pi p = 3.1416 octave:14> whos Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== a 1x1 8 double ans 1x1 8 double b 1x1 8 double p 1x1 8 double x 1x100 800 double Total is 104 elements using 832 bytes octave:15> a a = 17 octave:16> i*i ans = -1 octave:17> 17i ans = 0 + 17i octave:18> 2a parse error: syntax error >>> 2a ^ octave:18> j*j ans = -1 octave:19> j ans = 0 + 1i octave:20> whos Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== a 1x1 8 double c ans 1x1 16 double b 1x1 8 double p 1x1 8 double x 1x100 800 double Total is 104 elements using 840 bytes octave:21> pi ans = 3.1416 octave:22> e ans = 2.7183 octave:23> E error: 'E' undefined near line 23 column 1 octave:23> e ans = 2.7183 octave:24> Inf ans = Inf octave:25> 1/0 warning: division by zero ans = Inf octave:26> NaN ans = NaN octave:27> 0/0 warning: division by zero ans = NaN octave:28> -Inf ans = -Inf octave:29> 1/(-Inf) ans = -0 octave:30> pi ans = 3.1416 octave:31> format short octave:32> pi ans = 3.1416 octave:33> format long octave:34> pi ans = 3.14159265358979 octave:35> eps ans = 2.22044604925031e-16 octave:36> format bank octave:37> eps ans = 0.00 octave:38> pi ans = 3.14 octave:39> format + octave:40> pi ans = + octave:41> 17=12 error: invalid lvalue function called in expression octave:41> 17-12 ans = + octave:42> 12-17 ans = octave:43> 12-12 ans = octave:44> eps ans = + octave:45> eps/2 ans = + octave:46> format long octave:47> eps/2 ans = 1.11022302462516e-16 octave:48> whos Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== a 1x1 8 double ans 1x1 8 double b 1x1 8 double p 1x1 8 double x 1x100 800 double Total is 104 elements using 832 bytes octave:49> eps/4 ans = 5.55111512312578e-17 octave:50> eps/100 ans = 2.22044604925031e-18 octave:51> format - error: format: unrecognized format state '-' octave:51> format rat octave:52> pi ans = 355/113 octave:53> e ans = 25946/9545 octave:54> sqrt(2) ans = 8119/5741 octave:55> format short octave:56> format bit octave:57> e ans = 0100000000000101101111110000101010001011000101000101011101101001 octave:58> format hex octave:59> pi ans = 400921fb54442d18 octave:60> format bit octave:61> 1 ans = 0011111111110000000000000000000000000000000000000000000000000000 octave:62> 0 ans = 0000000000000000000000000000000000000000000000000000000000000000 octave:63> 2 ans = 0100000000000000000000000000000000000000000000000000000000000000 octave:64> 1 ans = 0011111111110000000000000000000000000000000000000000000000000000 octave:65> 2 ans = 0100000000000000000000000000000000000000000000000000000000000000 octave:66> 4 ans = 0100000000010000000000000000000000000000000000000000000000000000 octave:67> 8 ans = 0100000000100000000000000000000000000000000000000000000000000000 octave:68> -2 ans = 1100000000000000000000000000000000000000000000000000000000000000 octave:69> -4 ans = 1100000000010000000000000000000000000000000000000000000000000000 octave:70> format octal error: format: unrecognized format state 'octal' octave:70> format oct error: format: unrecognized format state 'oct' octave:70> format hex octave:71> format native-bit octave:72> 1 ans = 0000000000000000000000000000000000000000000000000000111111111100 octave:73> 2 ans = 0000000000000000000000000000000000000000000000000000000000000010 octave:74> 4 ans = 0000000000000000000000000000000000000000000000000000100000000010 octave:75> format hex octave:76> 16 ans = 4030000000000000 octave:77> 1 ans = 3ff0000000000000 octave:78> 2 ans = 4000000000000000 octave:79> 3 ans = 4008000000000000 octave:80> 4 ans = 4010000000000000 octave:81> 5 ans = 4014000000000000 octave:82> 6 ans = 4018000000000000 octave:83> 7 ans = 401c000000000000 octave:84> format short octave:85> wos error: 'wos' undefined near line 85 column 1 octave:85> whos Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== a 1x1 8 double ans 1x1 8 double b 1x1 8 double p 1x1 8 double x 1x100 800 double Total is 104 elements using 832 bytes octave:86> x x = Columns 1 through 7: 0.00000 0.10101 0.20202 0.30303 0.40404 0.50505 0.60606 Columns 8 through 14: 0.70707 0.80808 0.90909 1.01010 1.11111 1.21212 1.31313 Columns 15 through 21: 1.41414 1.51515 1.61616 1.71717 1.81818 1.91919 2.02020 Columns 22 through 28: 2.12121 2.22222 2.32323 2.42424 2.52525 2.62626 2.72727 Columns 29 through 35: 2.82828 2.92929 3.03030 3.13131 3.23232 3.33333 3.43434 Columns 36 through 42: 3.53535 3.63636 3.73737 3.83838 3.93939 4.04040 4.14141 Columns 43 through 49: 4.24242 4.34343 4.44444 4.54545 4.64646 4.74747 4.84848 Columns 50 through 56: 4.94949 5.05051 5.15152 5.25253 5.35354 5.45455 5.55556 Columns 57 through 63: 5.65657 5.75758 5.85859 5.95960 6.06061 6.16162 6.26263 Columns 64 through 70: 6.36364 6.46465 6.56566 6.66667 6.76768 6.86869 6.96970 Columns 71 through 77: 7.07071 7.17172 7.27273 7.37374 7.47475 7.57576 7.67677 Columns 78 through 84: 7.77778 7.87879 7.97980 8.08081 8.18182 8.28283 8.38384 Columns 85 through 91: 8.48485 8.58586 8.68687 8.78788 8.88889 8.98990 9.09091 Columns 92 through 98: 9.19192 9.29293 9.39394 9.49495 9.59596 9.69697 9.79798 Columns 99 and 100: 9.89899 10.00000 octave:87> length(x) ans = 100 octave:88> a=[1,2,3,4,5,6] a = 1 2 3 4 5 6 octave:89> b=[1 2 3 4 5 6] b = 1 2 3 4 5 6 octave:90> b b = 1 2 3 4 5 6 octave:91> b(2) ans = 2 octave:92> b(2 3) parse error: syntax error >>> b(2 3) ^ octave:92> b([2 3]) ans = 2 3 octave:93> b=[2 4 6 8] b = 2 4 6 8 octave:94> b[1] parse error: syntax error >>> b[1] ^ octave:94> b(1) ans = 2 octave:95> 0:10 ans = 0 1 2 3 4 5 6 7 8 9 10 octave:96> 1.1:1.1 ans = 1.1000 octave:97> 1.1:10.1 ans = Columns 1 through 7: 1.1000 2.1000 3.1000 4.1000 5.1000 6.1000 7.1000 Columns 8 through 10: 8.1000 9.1000 10.1000 octave:98> 1.1:10.2 ans = Columns 1 through 7: 1.1000 2.1000 3.1000 4.1000 5.1000 6.1000 7.1000 Columns 8 through 10: 8.1000 9.1000 10.1000 octave:99> 1:.1:10 ans = Columns 1 through 7: 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 Columns 8 through 14: 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 Columns 15 through 21: 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3.0000 Columns 22 through 28: 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 Columns 29 through 35: 3.8000 3.9000 4.0000 4.1000 4.2000 4.3000 4.4000 Columns 36 through 42: 4.5000 4.6000 4.7000 4.8000 4.9000 5.0000 5.1000 Columns 43 through 49: 5.2000 5.3000 5.4000 5.5000 5.6000 5.7000 5.8000 Columns 50 through 56: 5.9000 6.0000 6.1000 6.2000 6.3000 6.4000 6.5000 Columns 57 through 63: 6.6000 6.7000 6.8000 6.9000 7.0000 7.1000 7.2000 Columns 64 through 70: 7.3000 7.4000 7.5000 7.6000 7.7000 7.8000 7.9000 Columns 71 through 77: 8.0000 8.1000 8.2000 8.3000 8.4000 8.5000 8.6000 Columns 78 through 84: 8.7000 8.8000 8.9000 9.0000 9.1000 9.2000 9.3000 Columns 85 through 91: 9.4000 9.5000 9.6000 9.7000 9.8000 9.9000 10.0000 octave:100> 1:.1:2 ans = Columns 1 through 8: 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 Columns 9 through 11: 1.8000 1.9000 2.0000 octave:101> format bank octave:102> 1:.1:2 ans = 1.00 1.10 1.20 1.30 1.40 1.50 1.60 1.70 1.80 1.90 2.00 octave:103> 1:2:11 ans = 1.00 3.00 5.00 7.00 9.00 11.00 octave:104> x=[1 2 3 4 5 6] x = 1.00 2.00 3.00 4.00 5.00 6.00 octave:105> x=1:6 x = 1.00 2.00 3.00 4.00 5.00 6.00 octave:106> whos Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== a 1x6 48 double ans 1x6 24 double b 1x4 32 double p 1x1 8 double x 1x6 24 double Total is 23 elements using 136 bytes octave:107> rand(10) ans = 0.47 0.58 0.61 0.09 0.21 0.67 0.37 0.05 0.85 0.98 0.78 0.65 0.04 0.22 0.10 0.44 0.17 0.28 0.30 0.04 0.85 0.61 0.10 0.50 0.56 0.16 0.40 0.16 0.28 0.90 0.85 0.78 0.46 0.49 0.74 0.85 0.47 0.81 0.64 0.61 0.34 0.28 0.20 0.52 0.81 0.66 0.15 0.59 0.10 0.98 0.09 0.72 0.69 0.47 0.36 0.76 0.80 0.29 0.31 0.16 0.18 0.92 0.34 0.48 0.40 0.12 0.61 0.42 0.11 0.07 0.04 0.98 0.15 0.84 0.47 0.53 0.64 0.29 0.48 0.86 0.39 0.05 0.98 0.37 0.45 0.46 0.46 0.06 0.73 0.97 0.99 0.17 0.12 0.59 0.78 0.65 0.60 0.61 0.93 0.77 octave:108> r=rand(5) r = 0.39 0.45 0.63 0.39 0.69 0.42 0.01 0.66 0.38 0.74 0.42 0.64 0.88 0.50 0.28 0.28 0.57 0.14 0.75 0.27 0.82 0.55 0.07 0.62 0.62 octave:109> r(1,1) ans = 0.39 octave:110> r(2,2) ans = 0.01 octave:111> r(1,1:5) ans = 0.39 0.45 0.63 0.39 0.69 octave:112> r(2:4,2:4) ans = 0.01 0.66 0.38 0.64 0.88 0.50 0.57 0.14 0.75 octave:113> r(3,1:5) ans = 0.42 0.64 0.88 0.50 0.28 octave:114> r(3,:) ans = 0.42 0.64 0.88 0.50 0.28 octave:115> r(:,1) ans = 0.39 0.42 0.42 0.28 0.82 octave:116> [1,0,0,1] ans = 1.00 0.00 0.00 1.00 octave:117> roots([1,0,0,1]) ans = -1.00 0.50 0.50 octave:118> roots([1,0,0,-1]) ans = -0.50 -0.50 1.00 octave:119> format short octave:120> roots([1,0,0,-1]) ans = -0.50000 + 0.86603i -0.50000 - 0.86603i 1.00000 + 0.00000i octave:121> roots([1,1,1,1,1,1,1,1,1]) ans = 0.76604 + 0.64279i 0.76604 - 0.64279i 0.17365 + 0.98481i 0.17365 - 0.98481i -0.93969 + 0.34202i -0.93969 - 0.34202i -0.50000 + 0.86603i -0.50000 - 0.86603i octave:122> A=[1,2,3;4,5,6;7,8,9] A = 1 2 3 4 5 6 7 8 9 octave:123> v=[pi,e,sqrt(2)] v = 3.1416 2.7183 1.4142 octave:124> v=[pi;e;sqrt(2)] v = 3.1416 2.7183 1.4142 octave:125> A*v ans = 12.821 34.643 56.465 octave:126> A\v warning: matrix singular to machine precision, rcond = 2.20304e-18 ans = -2.028055 -0.095966 1.836124 octave:127> det(A) ans = -9.5171e-16 octave:128> A A = 1 2 3 4 5 6 7 8 9 octave:129> B=diag(1,2,3) B = 1 0 0 0 0 0 octave:130> B=diag([1 2 3])) parse error: syntax error >>> B=diag([1 2 3])) ^ octave:130> B=diag([1 2 3]) B = Diagonal Matrix 1 0 0 0 2 0 0 0 3 octave:131> det(B) ans = 6 octave:132> B\v ans = 3.14159 1.35914 0.47140 octave:133> det(A) ans = -9.5171e-16 octave:134> I=eye(20) I = Diagonal Matrix 1 0 0 0 0 0 0 0 0 0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 0.8836871 0.4963501 0.2772815 0.2847120 0.5691446 0.1442173 0.7535671 0.2701754 0.8232192 0.5472678 0.0745374 0.6189934 0.6195561 octave:138> diag([1 2 3]) ans = Diagonal Matrix 1 0 0 0 2 0 0 0 3 octave:139> r r = 0.3909133 0.4542052 0.6329048 0.3915995 0.6917856 0.4233359 0.0090191 0.6550963 0.3771462 0.7439145 0.4190284 0.6445332 0.8836871 0.4963501 0.2772815 0.2847120 0.5691446 0.1442173 0.7535671 0.2701754 0.8232192 0.5472678 0.0745374 0.6189934 0.6195561 octave:140> diag(r) ans = 0.3909133 0.0090191 0.8836871 0.7535671 0.6195561 octave:141> diag(diag(r)) ans = Diagonal Matrix 0.3909133 0 0 0 0 0 0.0090191 0 0 0 0 0 0.8836871 0 0 0 0 0 0.7535671 0 0 0 0 0 0.6195561 octave:142> r-diag(diag(r)) ans = 0.00000 0.45421 0.63290 0.39160 0.69179 0.42334 0.00000 0.65510 0.37715 0.74391 0.41903 0.64453 0.00000 0.49635 0.27728 0.28471 0.56914 0.14422 0.00000 0.27018 0.82322 0.54727 0.07454 0.61899 0.00000 octave:143> quit