octave:3> y0=pi y0 = 3.1416 octave:4> format long e octave:5> y1=pi y1 = 3.14159265358979e+00 octave:6> y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:7> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:8> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:9> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:10> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:11> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:12> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:13> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:14> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:15> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:16> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:17> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:18> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:19> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:20> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:21> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:22> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:23> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:24> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:25> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:26> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:27> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:28> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:29> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:30> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:31> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:32> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.14159265358979e+00 octave:33> y0=1/3 y0 = 3.33333333333333e-01 octave:34> y1=1/3 y1 = 3.33333333333333e-01 octave:35> y2=3*y1-2*y0 y2 = 3.33333333333333e-01 octave:36> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333333e-01 octave:37> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333333e-01 octave:38> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333333e-01 octave:39> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333333e-01 octave:40> 3*(1/3)-2*(1/3) ans = 3.33333333333333e-01 octave:41> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333332e-01 octave:42> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333330e-01 octave:43> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333326e-01 octave:44> clear all octave:45> y0=1/3 y0 = 3.33333333333333e-01 octave:46> y1=1/3 y1 = 3.33333333333333e-01 octave:47> y2=3*y1-2*y0 y2 = 3.33333333333333e-01 octave:48> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333333e-01 octave:49> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333333e-01 octave:50> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333333e-01 octave:51> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333333e-01 octave:52> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333332e-01 octave:53> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333330e-01 octave:54> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333326e-01 octave:55> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333319e-01 octave:56> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333305e-01 octave:57> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333277e-01 octave:58> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333220e-01 octave:59> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333333106e-01 octave:60> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333332879e-01 octave:61> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333332424e-01 octave:62> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333331514e-01 octave:63> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333329696e-01 octave:64> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333326058e-01 octave:65> sprintf(".20e",1/3) ans = .20e octave:66> sprintf("%.20e",1/3) ans = 3.33333333333333314830e-01 octave:67> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333318782e-01 octave:68> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333304230e-01 octave:69> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333275126e-01 octave:70> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333216918e-01 octave:71> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333333100503e-01 octave:72> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333332867672e-01 octave:73> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333332402011e-01 octave:74> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333331470688e-01 octave:75> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333329608043e-01 octave:76> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333325882753e-01 octave:77> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333318432172e-01 octave:78> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333303531011e-01 octave:79> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333273728689e-01 octave:80> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333214124044e-01 octave:81> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33333094914754e-01 octave:82> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33332856496175e-01 octave:83> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33332379659017e-01 octave:84> octave:84> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33331425984701e-01 octave:85> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33329518636068e-01 octave:86> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33325703938802e-01 octave:87> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33318074544271e-01 octave:88> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33302815755208e-01 octave:89> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33272298177083e-01 octave:90> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33211263020833e-01 octave:91> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.33089192708333e-01 octave:92> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.32845052083333e-01 octave:93> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.32356770833333e-01 octave:94> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.31380208333333e-01 octave:95> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.29427083333333e-01 octave:96> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.25520833333333e-01 octave:97> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.17708333333333e-01 octave:98> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 3.02083333333333e-01 octave:99> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 2.70833333333333e-01 octave:100> octave:100> y0=y1;y1=y2;y2=3*y1-2*y0 y2 = 2.08333333333333e-01 octave:101> 1/3==(3*1/3-2*1/3) ans = 0.00000000000000e+00 octave:102> docente.nome="Marco" docente = scalar structure containing the fields: nome = Marco octave:103> docente.cognome="Caliari" docente = scalar structure containing the fields: nome = Marco cognome = Caliari octave:104> docente.anni=20 docente = scalar structure containing the fields: nome = Marco cognome = Caliari anni = 2.00000000000000e+01 octave:105> docente.matrice=rand(2) docente = scalar structure containing the fields: nome = Marco cognome = Caliari anni = 2.00000000000000e+01 matrice = 5.16065112168399e-02 6.94977797530654e-01 4.77435878218403e-02 2.14089358773038e-01 octave:106> indirizzo.via=Pace error: 'Pace' undefined near line 1 column 15 octave:106> indirizzo.via="Pace" indirizzo = scalar structure containing the fields: via = Pace octave:107> indirizzo.numero=12 indirizzo = scalar structure containing the fields: via = Pace numero = 1.20000000000000e+01 octave:108> docente.indirizzo=indirizzo docente = scalar structure containing the fields: nome = Marco cognome = Caliari anni = 2.00000000000000e+01 matrice = 5.16065112168399e-02 6.94977797530654e-01 4.77435878218403e-02 2.14089358773038e-01 indirizzo = scalar structure containing the fields: via = Pace numero = 1.20000000000000e+01 octave:109> docente.anni ans = 2.00000000000000e+01 octave:110> help fieldnames 'fieldnames' is a function from the file /usr/share/octave/3.8.1/m/general/fieldnames.m -- Function File: NAMES = fieldnames (STRUCT) -- Function File: NAMES = fieldnames (OBJ) -- Function File: NAMES = fieldnames (JAVAOBJ) -- Function File: NAMES = fieldnames ("JCLASSNAME") Return a cell array of strings with the names of the fields in the specified input. When the input is a structure STRUCT, the names are the elements of the structure. When the input is an Octave object OBJ, the names are the public properties of the object. When the input is a Java object JAVAOBJ or Java classname JCLASSNAME the name are the public data elements of the object or class. See also: nfields, isfield, orderfields, struct, methods. 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:111> fieldnames (docente) ans = { [1,1] = nome [2,1] = cognome [3,1] = anni [4,1] = matrice [5,1] = indirizzo } octave:112> help rk2 'rk2' is a function from the file /home/accounts/personale/clrmrc90/aa1617/equazioni_differenziali/rk2.m function [tout,yout]=rk2(odefun,tspan,y0,options) The structure options may contain the fields: * InitialStep: initial step 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:113> clear all octave:114> a(1)=1 a = 1.00000000000000e+00 octave:115> a(2)=2 a = 1.00000000000000e+00 2.00000000000000e+00 octave:116> odefun=@(t,y) y; octave:117> tspan=[0,1]; octave:118> k=0.05 k = 5.00000000000000e-02 octave:119> format bit octave:120> k k = 0011111110101001100110011001100110011001100110011001100110011010 octave:121> k=0.06125 k = 0011111110101111010111000010100011110101110000101000111101011100 octave:122> k=0.0625 k = 0011111110110000000000000000000000000000000000000000000000000000 octave:123> 2^(-8) ans = 0011111101110000000000000000000000000000000000000000000000000000 octave:124> 2^(-6) ans = 0011111110010000000000000000000000000000000000000000000000000000 octave:125> 2^(-5) ans = 0011111110100000000000000000000000000000000000000000000000000000 octave:126> 2^(-4) ans = 0011111110110000000000000000000000000000000000000000000000000000 octave:127> 0.0625 ans = 0011111110110000000000000000000000000000000000000000000000000000 octave:128> y0=1 y0 = 0011111111110000000000000000000000000000000000000000000000000000 octave:129> format octave:130> [tout,yout]=rk2(odefun,tspan,y0); octave:131> tout tout = 0.00000 0.06250 0.12500 0.18750 0.25000 0.31250 0.37500 0.43750 0.50000 0.56250 0.62500 0.68750 0.75000 0.81250 0.87500 0.93750 1.00000 octave:132> yout yout = 1.0000 1.0645 1.1331 1.2061 1.2838 1.3666 1.4547 1.5484 1.6482 1.7544 1.8675 1.9879 2.1160 2.2524 2.3976 2.5521 2.7166 octave:133> plot(tout,yout,'*',tout,exp(tout)) octave:134> exp(1)-yout(end) ans = 0.0016883 octave:135> options.InitialStep=0.0625/2 options = scalar structure containing the fields: InitialStep = 0.031250 octave:136> [tout,yout]=rk2(odefun,tspan,y0,options); octave:137> tout tout = 0.00000 0.03125 0.06250 0.09375 0.12500 0.15625 0.18750 0.21875 0.25000 0.28125 0.31250 0.34375 0.37500 0.40625 0.43750 0.46875 0.50000 0.53125 0.56250 0.59375 0.62500 0.65625 0.68750 0.71875 0.75000 0.78125 0.81250 0.84375 0.87500 0.90625 0.93750 0.96875 1.00000 octave:138> exp(1)-yout(end) ans = 4.3215e-04 octave:139> ans*4 ans = 0.0017286 octave:140> options.InitialStep=2^(-6) options = scalar structure containing the fields: InitialStep = 0.015625 octave:141> [tout,yout]=rk2(odefun,tspan,y0,options); octave:142> exp(1)-yout(end) ans = 1.0932e-04 octave:143> ans*4 ans = 4.3727e-04 octave:144> options.InitialStep=0.01 options = scalar structure containing the fields: InitialStep = 0.010000 octave:145> [tout,yout]=rk2(odefun,tspan,y0,options); octave:146> tout tout = 0.00000 0.01000 0.02000 0.03000 0.04000 0.05000 0.06000 0.07000 0.08000 0.09000 0.10000 0.11000 0.12000 0.13000 0.14000 0.15000 0.16000 0.17000 0.18000 0.19000 0.20000 0.21000 0.22000 0.23000 0.24000 0.25000 0.26000 0.27000 0.28000 0.29000 0.30000 0.31000 0.32000 0.33000 0.34000 0.35000 0.36000 0.37000 0.38000 0.39000 0.40000 0.41000 0.42000 0.43000 0.44000 0.45000 0.46000 0.47000 0.48000 0.49000 0.50000 0.51000 0.52000 0.53000 0.54000 0.55000 0.56000 0.57000 0.58000 0.59000 0.60000 0.61000 0.62000 0.63000 0.64000 0.65000 0.66000 0.67000 0.68000 0.69000 0.70000 0.71000 0.72000 0.73000 0.74000 0.75000 0.76000 0.77000 0.78000 0.79000 0.80000 0.81000 0.82000 0.83000 0.84000 0.85000 0.86000 0.87000 0.88000 0.89000 0.90000 0.91000 0.92000 0.93000 0.94000 0.95000 0.96000 0.97000 0.98000 0.99000 1.00000 octave:147> options.InitialStep=0.1 options = scalar structure containing the fields: InitialStep = 0.10000 octave:148> [tout,yout]=rk2(odefun,tspan,y0,options); octave:149> tout tout = 0.00000 0.10000 0.20000 0.30000 0.40000 0.50000 0.60000 0.70000 0.80000 0.90000 1.00000 1.00000 octave:150> options.InitialStep=0.1 options = scalar structure containing the fields: InitialStep = 0.10000 octave:151> [tout,yout]=rk2(odefun,tspan,y0,options); octave:152> tout tout = 0.00000 0.10000 0.20000 0.30000 0.40000 0.50000 0.60000 0.70000 0.80000 0.90000 1.00000 1.00000 octave:153> format long e octave:154> tout tout = 0.00000000000000e+00 1.00000000000000e-01 2.00000000000000e-01 3.00000000000000e-01 4.00000000000000e-01 5.00000000000000e-01 6.00000000000000e-01 7.00000000000000e-01 8.00000000000000e-01 9.00000000000000e-01 1.00000000000000e+00 1.00000000000000e+00 octave:155> yout yout = 1.00000000000000e+00 1.10500000000000e+00 1.22102500000000e+00 1.34923262500000e+00 1.49090205062500e+00 1.64744676594062e+00 1.82042867636439e+00 2.01157368738265e+00 2.22278892455783e+00 2.45618176163640e+00 2.71408084660822e+00 2.71408084660822e+00 octave:156> diff(tout) ans = 1.00000000000000e-01 1.00000000000000e-01 1.00000000000000e-01 1.00000000000000e-01 1.00000000000000e-01 1.00000000000000e-01 1.00000000000000e-01 1.00000000000000e-01 1.00000000000000e-01 1.00000000000000e-01 1.11022302462516e-16 octave:157> [tout,yout]=rk2(odefun,tspan,y0,options); octave:158> tout tout = 0.00000000000000e+00 1.00000000000000e-01 2.00000000000000e-01 3.00000000000000e-01 4.00000000000000e-01 5.00000000000000e-01 6.00000000000000e-01 7.00000000000000e-01 8.00000000000000e-01 9.00000000000000e-01 1.00000000000000e+00 1.00000000000000e+00 octave:159> [tout,yout]=rk2(odefun,tspan,y0,options); octave:160> tout(end)==1 ans = 1.00000000000000e+00 octave:161> tout(end-1)==1 ans = 0.00000000000000e+00 octave:162> diary off