octave:2> options.nome error: 'options' undefined near line 1 column 1 octave:2> options.nome='Marco' options = scalar structure containing the fields: nome = Marco octave:3> options.a error: structure has no member 'a' octave:3> options.a=20 options = scalar structure containing the fields: nome = Marco a = 20 octave:4> options.b=rand(2) options = scalar structure containing the fields: nome = Marco a = 20 b = 0.477622 0.040637 0.531443 0.033922 octave:5> options.b=[1;2] options = scalar structure containing the fields: nome = Marco a = 20 b = 1 2 octave:6> options.a=[] options = scalar structure containing the fields: nome = Marco a = [](0x0) b = 1 2 octave:7> f = @(y) y; octave:8> f(1,2) ans = 1 octave:9> f = @(t,y) y.*(1-y); octave:10> y0 = 1/2; octave:11> tspan=[0,1]; octave:12> [tout,yout]=rk2(f,tspan,y0); octave:13> tout tout = 0.00000 0.05000 0.10000 0.15000 0.20000 0.25000 0.30000 0.35000 0.40000 0.45000 0.50000 0.55000 0.60000 0.65000 0.70000 0.75000 0.80000 0.85000 0.90000 0.95000 1.00000 octave:14> yout yout = 0.50000 0.51250 0.52498 0.53743 0.54984 0.56218 0.57445 0.58662 0.59869 0.61064 0.62246 0.63414 0.64566 0.65702 0.66819 0.67918 0.68998 0.70057 0.71095 0.72112 0.73106 octave:15> plot(tout,yout) octave:16> size(tout) ans = 21 1 octave:17> options.InitialStep=0.001; octave:18> [tout,yrif]=rk2(f,tspan,y0,options); octave:19> length(yrif) ans = 1001 octave:20> 1/50 ans = 0.020000 octave:21> options.InitialStep=0.02; octave:22> [tout,yout]=rk2(f,tspan,y0,options); octave:23> errore(1)=abs(yrif(end)-yout(end)); octave:24> options.InitialStep=0.01; octave:25> [tout,yout]=rk2(f,tspan,y0,options); octave:26> errore(2)=abs(yrif(end)-yout(end)); octave:27> options.InitialStep=0.005; octave:28> [tout,yout]=rk2(f,tspan,y0,options); octave:29> errore(3)=abs(yrif(end)-yout(end)); octave:30> loglog([50,100,200],errore,'*') octave:31> loglog([50,100,200],errore,'*',[50,100,200],[50,100,200].^(-2)) octave:32> [tout,yout]=rk23(f,tspan,y0,options); octave:33> tout tout = Columns 1 through 7: 0.00000 0.00500 0.01500 0.03500 0.07500 0.15500 0.31500 Columns 8 and 9: 0.63500 1.00000 octave:34> diff(tout) ans = Columns 1 through 6: 0.0050000 0.0100000 0.0200000 0.0400000 0.0800000 0.1600000 Columns 7 and 8: 0.3200000 0.3650000 octave:35> f = @(t,y) [-2*y(2)*y(1);y(1)^2+y(3)^2-y(2)^2-1;-2*(y(2)+y(1))*y(3)]; octave:36> y0=[0.5,2,10]; octave:37> tspan=[0,15]; octave:38> [tout,yout]=rk23(f,tspan,y0); octave:39> size(yout) ans = 416 3 octave:40> E=(yout(:,1).^2+yout(:,2).^2+yout(:,3).^2+1)./(2*yout(:,1)); octave:41> plot(tout,E) octave:42> plot(tout,E,'.') octave:43> options.AbsTol=1e-3; octave:44> options.RelTol=1e-3; octave:45> [tout,yout]=rk23(f,tspan,y0,options); octave:46> E=(yout(:,1).^2+yout(:,2).^2+yout(:,3).^2+1)./(2*yout(:,1)); octave:47> plot(tout,E,'.') octave:48> plot(tout,yout(:,1),'.') octave:49> options options = scalar structure containing the fields: nome = Marco a = [](0x0) b = 1 2 InitialStep = 0.0050000 AbsTol = 0.0010000 RelTol = 0.0010000 octave:50> help struct 'struct' is a built-in function from the file libinterp/octave-value/ov-struct.cc -- Built-in Function: S = struct () -- Built-in Function: S = struct (FIELD1, VALUE1, FIELD2, VALUE2, ...) -- Built-in Function: S = struct (OBJ) Create a scalar or array structure and initialize its values. The FIELD1, FIELD2, ... variables are strings specifying the names of the fields and the VALUE1, VALUE2, ... variables can be of any type. If the values are cell arrays, create a structure array and initialize its values. The dimensions of each cell array of values must match. Singleton cells and non-cell values are repeated so that they fill the entire array. If the cells are empty, create an empty structure array with the specified field names. If the argument is an object, return the underlying struct. Observe that the syntax is optimized for struct *arrays*. Consider the following examples: struct ("foo", 1) => scalar structure containing the fields: foo = 1 struct ("foo", {}) => 0x0 struct array containing the fields: foo struct ("foo", { {} }) => scalar structure containing the fields: foo = {}(0x0) struct ("foo", {1, 2, 3}) => 1x3 struct array containing the fields: foo The first case is an ordinary scalar struct--one field, one value. The second produces an empty struct array with one field and no values, since s being passed an empty cell array of struct array values. When the value is a cell array containing a single entry, this becomes a scalar struct with that single entry as the value of the field. That single entry happens to be an empty cell array. Finally, if the value is a non-scalar cell array, then 'struct' produces a struct *array*. See also: cell2struct, fieldnames, orderfields, getfield, setfield, rmfield, structfun. 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:51> rmfield (options,'nome') ans = scalar structure containing the fields: a = [](0x0) b = 1 2 InitialStep = 0.0050000 AbsTol = 0.0010000 RelTol = 0.0010000 octave:52> rmfield (options,'a') ans = scalar structure containing the fields: nome = Marco b = 1 2 InitialStep = 0.0050000 AbsTol = 0.0010000 RelTol = 0.0010000 octave:53> options=rmfield (options,'a','nome') error: Invalid call to rmfield. Correct usage is: -- Built-in Function: S = rmfield (S, "F") -- Built-in Function: S = rmfield (S, F) 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:53> options=rmfield (options,'a') options = scalar structure containing the fields: nome = Marco b = 1 2 InitialStep = 0.0050000 AbsTol = 0.0010000 RelTol = 0.0010000 octave:54> options=rmfield (options,'b') options = scalar structure containing the fields: nome = Marco InitialStep = 0.0050000 AbsTol = 0.0010000 RelTol = 0.0010000 octave:55> octave:55> options=rmfield (options,'nome') options = scalar structure containing the fields: InitialStep = 0.0050000 AbsTol = 0.0010000 RelTol = 0.0010000 octave:56> options=rmfield (options,'InitialStep') options = scalar structure containing the fields: AbsTol = 0.0010000 RelTol = 0.0010000 octave:57> y0=1/3 y0 = 0.33333 octave:58> y1=1/3 y1 = 0.33333 octave:59> y2=3*y1-2*y0 y2 = 0.33333 octave:60> y0=y1 y0 = 0.33333 octave:61> y1=y2 y1 = 0.33333 octave:62> y2=3*y1-2*y0 y2 = 0.33333 octave:63> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:64> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:65> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:66> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:67> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:68> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:69> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:70> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:71> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:72> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:73> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:74> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:75> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:76> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:77> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:78> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:79> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:80> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:81> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:82> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:83> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:84> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:85> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:86> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:87> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:88> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:89> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:90> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:91> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:92> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:93> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:94> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:95> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:96> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:97> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:98> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33333 octave:99> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33332 octave:100> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33330 octave:101> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33327 octave:102> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33321 octave:103> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33309 octave:104> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33285 octave:105> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33236 octave:106> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.33138 octave:107> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.32943 octave:108> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.32552 octave:109> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.31771 octave:110> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.30208 octave:111> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.27083 octave:112> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.20833 octave:113> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = 0.083333 octave:114> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -0.16667 octave:115> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -0.66667 octave:116> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -1.6667 octave:117> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -3.6667 octave:118> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -7.6667 octave:119> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -15.667 octave:120> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -31.667 octave:121> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -63.667 octave:122> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -127.67 octave:123> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -255.67 octave:124> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -511.67 octave:125> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -1023.7 octave:126> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -2047.7 octave:127> y0=y1;,y1=y2;,y2=3*y1-2*y0 y2 = -4095.7 octave:128> diary off