]> Creatis software - CreaPhase.git/blob - octave_packages/secs2d-0.0.8/Utilities/UDXoutput2Dtimeseries.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / secs2d-0.0.8 / Utilities / UDXoutput2Dtimeseries.m
1 function UDXoutput2Dtimeseries(filename,p,t,u,attr_name,attr_rank,attr_shape,time)
2
3 ##
4 ##   UDXoutput2Dtimeseries(filename,p,t,u,attr_name,attr_rank,attr_shape,time)
5 ##
6 ##   Outputs data in DX form.
7 ##   Only one variable can be written to the file
8 ##   variable must be a scalar, vector or tensor of doubles   
9 ##
10 ##   attr_name  = name of the variable                   (type string)
11 ##   attr_rank  = rank of variable data                  (0 for scalar, 1 for vector, etc.)
12 ##   attr_shape = number of components of variable data  (assumed 1 for scalar)
13 ##
14
15
16 % This file is part of 
17 %
18 %            SECS2D - A 2-D Drift--Diffusion Semiconductor Device Simulator
19 %         -------------------------------------------------------------------
20 %            Copyright (C) 2004-2006  Carlo de Falco
21 %
22 %
23 %
24 %  SECS2D is free software; you can redistribute it and/or modify
25 %  it under the terms of the GNU General Public License as published by
26 %  the Free Software Foundation; either version 2 of the License, or
27 %  (at your option) any later version.
28 %
29 %  SECS2D is distributed in the hope that it will be useful,
30 %  but WITHOUT ANY WARRANTY; without even the implied warranty of
31 %  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32 %  GNU General Public License for more details.
33 %
34 %  You should have received a copy of the GNU General Public License
35 %  along with SECS2D; If not, see <http://www.gnu.org/licenses/>.
36
37 Nsteps = length(time);
38 if (Nsteps<=1)
39         endfile = 1;
40 else
41         endfile = 0;
42 end
43
44 UDXoutput2Ddata(filename,p,t,u(:,1:attr_shape),[attr_name "1"],attr_rank,attr_shape,endfile);
45
46 for it = 2:Nsteps
47         UDXappend2Ddata(filename,p,t,u(:,[1:attr_shape]+attr_shape*(it-1)),...
48                 [attr_name num2str(it)],attr_rank,attr_shape,endfile);
49 end
50
51 fid=fopen(filename,"a");
52
53 fprintf (fid, "object \"%s_series\" class series\n",attr_name);
54 for it = 1:Nsteps
55         fprintf (fid,"member %d position %g value \"%s\"\n",it-1,time(it),[attr_name num2str(it)]);
56 end
57 fprintf (fid, "\nend\n");
58 fclose(fid);