1
2
3
4
5
6
7
8
9
10
11
12
|
function [x] = mtt_update(dx,x,AAx,AA,dt,STEPFACTOR,Nx,METHOD);
if (METHOD==1) #Euler
ddt = dt/STEPFACTOR;
x = x + dx*ddt;
elseif ((METHOD==2)||(METHOD==3))#Linear implicit or Implicit
x = AA\(AAx + dx*dt);
else
error("Method %i is not defined", METHOD);
endif;
endfunction;
|
|
|
|
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
function [x] = mtt_update(dx,x,dt,STEPFACTOR,METHOD,name);
if (METHOD==1) #Euler
ddt = dt/STEPFACTOR;
x = x + dx*ddt;
elseif (METHOD==2) #Linear implicit or Implicit
eval("[AA,AAx] = ",name,"_smx;");
x = AA\(AAx + dx*dt);
else
error("Method %i is not defined", METHOD);
endif;
endfunction;
|