octave:2> x=linspace(0,1,11) x = Columns 1 through 8: 0.00000 0.10000 0.20000 0.30000 0.40000 0.50000 0.60000 0.70000 Columns 9 through 11: 0.80000 0.90000 1.00000 octave:3> g=@(x) 2 * (x>=1/2); octave:4> g(x) ans = 0 0 0 0 0 2 2 2 2 2 2 octave:5> g=@(x) 2 * (x>=1/2 & x < 0.8); octave:6> g(x) ans = 0 0 0 0 0 2 2 2 0 0 0 octave:7> g=@(x) x .* (x>=1/2 & x < 0.8); octave:8> g(x) ans = Columns 1 through 8: 0.00000 0.00000 0.00000 0.00000 0.00000 0.50000 0.60000 0.70000 Columns 9 through 11: 0.00000 0.00000 0.00000 octave:9> fem0 error: 'fem0' undefined near line 1 column 1 octave:9> ls 2019-10-17.txt 2019-12-05.txt jacobi.m qr_shift.m 2019-10-31.txt 2019-12-11.txt potenze.m spline_notaknot.m 2019-11-14.txt gaussseidel.m potenzeOP.m octave:10> cd .. octave:11> cd equazioni_differenziali/ octave:12> fem0 ans = 2.6368e-15 ans = 4.7744e-05 octave:13> x x = 0.00000 0.00962 0.01923 0.02885 0.03846 0.04808 0.05769 0.06731 0.07692 0.08654 0.09615 0.10577 0.11538 0.12500 0.13462 0.14423 0.15385 0.16346 0.17308 0.18269 0.19231 0.20192 0.21154 0.22115 0.23077 0.24038 0.25000 0.26923 0.28846 0.30769 0.32692 0.34615 0.36538 0.38462 0.40385 0.42308 0.44231 0.46154 0.48077 0.50000 0.51923 0.53846 0.55769 0.57692 0.59615 0.61538 0.63462 0.65385 0.67308 0.69231 0.71154 0.73077 0.75000 0.75962 0.76923 0.77885 0.78846 0.79808 0.80769 0.81731 0.82692 0.83654 0.84615 0.85577 0.86538 0.87500 0.88462 0.89423 0.90385 0.91346 0.92308 0.93269 0.94231 0.95192 0.96154 0.97115 0.98077 0.99038 1.00000 octave:14> plot(x,zeros(length(x),1),'*') octave:15> length(x) ans = 79 octave:16> x=linspace(0,1,11) x = Columns 1 through 8: 0.00000 0.10000 0.20000 0.30000 0.40000 0.50000 0.60000 0.70000 Columns 9 through 11: 0.80000 0.90000 1.00000 octave:17> idx1=(x>=1/2) idx1 = 0 0 0 0 0 1 1 1 1 1 1 octave:18> u=zeros(size(x)) u = 0 0 0 0 0 0 0 0 0 0 0 octave:19> u(idx1)=x(idx1).^2 u = Columns 1 through 9: 0.00000 0.00000 0.00000 0.00000 0.00000 0.25000 0.36000 0.49000 0.64000 Columns 10 and 11: 0.81000 1.00000 octave:20> idx2=[0,0,0,0,0,1,1,1,1,1,1] idx2 = 0 0 0 0 0 1 1 1 1 1 1 octave:21> idx1 idx1 = 0 0 0 0 0 1 1 1 1 1 1 octave:22> idx2 idx2 = 0 0 0 0 0 1 1 1 1 1 1 octave:23> u(idx1) ans = 0.25000 0.36000 0.49000 0.64000 0.81000 1.00000 octave:24> u(idx2) error: u(0): subscripts must be either integers 1 to (2^31)-1 or logicals octave:24> whos Variables in the current scope: Attr Name Size Bytes Class ==== ==== ==== ===== ===== A 79x79 3140 double M 1x1 8 double ans 1x6 48 double epsilon 1x1 8 double g 79x1 632 double gepsilon 1x1 0 function_handle h 78x1 624 double idx1 1x11 11 logical idx2 1x11 88 double idx3 1001x1 1001 logical m 1x1 8 double mm 1x1 8 double n1 1x1 8 double n2 1x1 8 double u 1x11 88 double uesatta 79x1 632 double uhat 79x1 632 double uuesatta 1001x1 8008 double uuhat 1001x1 8008 double x 1x11 88 double xl 27x1 216 double xm 27x1 216 double xr 27x1 216 double xx 1001x1 8008 double Total is 10698 elements using 31704 bytes octave:25> fem0 ans = 2.6368e-15 ans = 4.7744e-05 octave:26> fem0 ans = 9.4369e-16 ans = 2.2413e-04 octave:27> fem0 ans = 2.7756e-16 ans = 8.9652e-04 octave:28> fem0 ans = 4.3368e-19 ans = 0.0080687 octave:29> fem0 ans = 2.7756e-16 ans = 8.9652e-04 octave:30> 0.0080687 ans = 0.0080687 octave:31> 0.0080687/4 ans = 0.0020172 octave:32> fem0 ans = 9.4369e-16 ans = 2.2413e-04 octave:33> 8.9652e-04/4 ans = 2.2413e-04 octave:34> fem0 ans = 2.6368e-15 ans = 4.7744e-05 octave:35> 2.2413e-04/4 ans = 5.6033e-05 octave:36> clear all octave:37> i ans = 0 + 1i octave:38> i=2 i = 2 octave:39> i i = 2 octave:40> 1i ans = 0 + 1i octave:41> 1i=2 parse error: invalid constant left hand side of assignment >>> 1i=2 ^ octave:41> 2i ans = 0 + 2i octave:42> 2i ans = 0 + 2i octave:43> 2*1i ans = 0 + 2i octave:44> 3.5i ans = 0.00000 + 3.50000i octave:45> pi ans = 3.1416 octave:46> pi=2 pi = 2 octave:47> pi pi = 2 octave:48> sqrt(-1) ans = 0 + 1i octave:49> unitaimmaginaria=sqrt(-1) unitaimmaginaria = 0 + 1i octave:50> e ans = 2.7183 octave:51> exp(1) ans = 2.7183 octave:52> v=rand(1,2)+1i*rand(1,2) v = 0.32127 + 0.26676i 0.41609 + 0.88473i octave:53> v' ans = 0.32127 - 0.26676i 0.41609 - 0.88473i octave:54> v.' ans = 0.32127 + 0.26676i 0.41609 + 0.88473i octave:55> transpose(v) ans = 0.32127 + 0.26676i 0.41609 + 0.88473i octave:56> help transpose 'transpose' is a built-in function from the file libinterp/corefcn/data.cc -- transpose (X) Return the transpose of X. This function and X.' are equivalent. See also: ctranspose. Additional help for built-in functions and operators is available in the online version of the manual. Use the command 'doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. octave:57> ctranspose (v) ans = 0.32127 - 0.26676i 0.41609 - 0.88473i octave:58> diary off