y0=exp(1)
y0 =
2.7183
y1=exp(1);
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.7183
format long e
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828459048e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828459052e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828459059e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828459073e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828459101e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828459158e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828459272e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828459499e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828459954e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828460864e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828462683e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828466321e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828473597e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828488148e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828517252e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828575460e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828691875e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281828924706e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281829390367e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281830321690e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281832184335e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281835909625e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281843360206e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281858261367e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281888063689e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718281947668334e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718282066877624e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718282305296203e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718282782133361e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718283735807677e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718285643156310e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718289457853576e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718297087248107e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718312346037170e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718342863615295e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718403898771545e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718525969084045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.718770109709045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.719258390959045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.720234953459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.722188078459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.726094328459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.733906828459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.749531828459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.780781828459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.843281828459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.968281828459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
3.218281828459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
3.718281828459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
4.718281828459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
6.718281828459045e+00
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
1.071828182845904e+01
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
1.871828182845905e+01
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
3.471828182845906e+01
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
6.671828182845907e+01
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
1.307182818284591e+02
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.587182818284592e+02
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
5.147182818284595e+02
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
1.026718281828460e+03
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
2.050718281828460e+03
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
4.098718281828460e+03
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
8.194718281828460e+03
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
1.638671828182846e+04
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
3.277071828182846e+04
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
6.553871828182845e+04
y2=3*y1-2*y0,y0=y1;,y1=y2;
y2 =
1.310747182818284e+05
3*exp(1)-2*exp(1)==exp(1)
ans =
0
3*exp(1)-2*exp(1)
ans =
2.718281828459046e+00
exp(1)
ans =
2.718281828459046e+00
y0=exp(1);,y1=exp(1);
y2=4*y1/3-y0,y0=y1;y1=y2;
y2 =
9.060939428196817e-01
y0=exp(1);y1=exp(1);
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
y2=4*y1/3-y0/3,y0=y1;y1=y2;
y2 =
2.718281828459046e+00
uiopen('/home/accounts/personale/clrmrc90/aa1213/equazioni_differenziali/rk2.m', true);
help cell
CELL Create cell array.
CELL(N) is an N-by-N cell array of empty matrices.
CELL(M,N) or CELL([M,N]) is an M-by-N cell array of empty
matrices.
CELL(M,N,P,...) or CELL([M N P ...]) is an M-by-N-by-P-by-...
cell array of empty matrices.
CELL(SIZE(A)) is a cell array the same size as A containing
all empty matrices.
See also ones, zeros, struct, deal, paren.
Reference page in Help browser
doc cell
help struct
STRUCT Create or convert to structure array.
S = STRUCT('field1',VALUES1,'field2',VALUES2,...) creates a
structure array with the specified fields and values. The value
arrays VALUES1, VALUES2, etc. must be cell arrays of the same
size, scalar cells or single values. Corresponding elements of the
value arrays are placed into corresponding structure array elements.
The size of the resulting structure is the same size as the value
cell arrays or 1-by-1 if none of the values is a cell.
STRUCT(OBJ) converts the object OBJ into its equivalent
structure. The class information is lost.
STRUCT([]) creates an empty structure.
To create fields that contain cell arrays, place the cell arrays
within a VALUE cell array. For instance,
s = struct('strings',{{'hello','yes'}},'lengths',[5 3])
creates the 1-by-1 structure
s =
strings: {'hello' 'yes'}
lengths: [5 3]
Example
s = struct('type',{'big','little'},'color','red','x',{3 4})
See also isstruct, setfield, getfield, fieldnames, orderfields,
isfield, rmfield, deal, substruct, struct2cell, cell2struct.
Overloaded methods:
memmapfile/struct
Reference page in Help browser
doc struct
a{1}=3
a =
[3]
a{2}=[1,4]
a =
[3] [1x2 double]
a{1}
ans =
3
a{2}
ans =
1 4
a
a =
[3] [1x2 double]
clear all
a.nome='Marco'
a =
nome: 'Marco'
a.nome
ans =
Marco
a.cognome='Caliari'
a =
nome: 'Marco'
cognome: 'Caliari'
a.age=30
a =
nome: 'Marco'
cognome: 'Caliari'
age: 30
a.cognome
ans =
Caliari
options.InitialStep=0.03
options =
InitialStep: 3.000000000000000e-02
edit
[tout,yout]=rk2(@odefun,[0,1],1);
plot(tout,yout)
plot(tout,yout,'*',tout,exp(tout))
diff(tout)
ans =
5.000000000000000e-02
5.000000000000000e-02
5.000000000000002e-02
4.999999999999999e-02
4.999999999999999e-02
4.999999999999999e-02
4.999999999999999e-02
4.999999999999999e-02
4.999999999999999e-02
4.999999999999999e-02
4.999999999999999e-02
5.000000000000004e-02
5.000000000000004e-02
5.000000000000004e-02
5.000000000000004e-02
5.000000000000004e-02
5.000000000000004e-02
5.000000000000004e-02
5.000000000000004e-02
4.999999999999971e-02
tout
tout =
0
5.000000000000000e-02
1.000000000000000e-01
1.500000000000000e-01
2.000000000000000e-01
2.500000000000000e-01
3.000000000000000e-01
3.500000000000000e-01
4.000000000000000e-01
4.500000000000000e-01
4.999999999999999e-01
5.499999999999999e-01
6.000000000000000e-01
6.500000000000000e-01
7.000000000000001e-01
7.500000000000001e-01
8.000000000000002e-01
8.500000000000002e-01
9.000000000000002e-01
9.500000000000003e-01
1.000000000000000e+00
options.InitialStep=0.1;
[tout,yout]=rk2(@odefun,[0,1],1,options);
diff(tout)
ans =
1.000000000000000e-01
1.000000000000000e-01
1.000000000000000e-01
9.999999999999998e-02
9.999999999999998e-02
9.999999999999998e-02
9.999999999999998e-02
9.999999999999998e-02
9.999999999999998e-02
9.999999999999998e-02
1.110223024625157e-16
clear options
options.InitialSept=0.1;
[tout,yout]=rk2(@odefun,[0,1],[1,2]);
tout
tout =
0
5.000000000000000e-02
1.000000000000000e-01
1.500000000000000e-01
2.000000000000000e-01
2.500000000000000e-01
3.000000000000000e-01
3.500000000000000e-01
4.000000000000000e-01
4.500000000000000e-01
4.999999999999999e-01
5.499999999999999e-01
6.000000000000000e-01
6.500000000000000e-01
7.000000000000001e-01
7.500000000000001e-01
8.000000000000002e-01
8.500000000000002e-01
9.000000000000002e-01
9.500000000000003e-01
1.000000000000000e+00
yout
yout =
Column 1
1.000000000000000e+00
1.216250000000000e+00
1.470189062500000e+00
1.768039009765625e+00
2.117032336525879e+00
2.525575560343546e+00
3.003438931678896e+00
3.561976755143856e+00
4.214383259048793e+00
4.975989746505473e+00
5.864609685894964e+00
6.900939472140242e+00
8.109023836980299e+00
9.516796334242386e+00
1.115670700736987e+01
1.306645129883100e+01
1.528981652822452e+01
1.787766489867742e+01
2.088907504844878e+01
2.439266771496982e+01
2.846814520135900e+01
Column 2
2.000000000000000e+00
2.267500000000000e+00
2.575315625000000e+00
2.929803308593750e+00
3.338337055668946e+00
3.809472146342694e+00
4.353135217710500e+00
4.980844975834581e+00
5.705968476049917e+00
6.544018705877905e+00
7.513000129435233e+00
8.633809925911949e+00
9.930703901507808e+00
1.143183750207693e+01
1.316989403505593e+01
1.518281416168597e+01
1.751464298780081e+01
2.021651371430699e+01
2.334778986587937e+01
2.697739166679373e+01
3.118533625571388e+01
plot(tout,yout)
diary off