Overview
Comment:Unified format of time responses.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 94c73ad0d86f19c25ae18c4895eaea2823b739400bee7df67557ea38d457ff98
User & Date: gawthrop@users.sourceforge.net on 1996-08-18 12:03:06
Other Links: branch diff | manifest | tags
Context
1996-08-18
12:03:49
Initial revision check-in: 83fd3b2cd7 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
12:03:06
Unified format of time responses. check-in: 94c73ad0d8 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
12:02:46
Fixed bug when some matrices are empty. check-in: 7dbc0b1aab user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/mtt from [5d5211360a] to [85a6ac0bcf].

15
16
17
18
19
20
21



22
23
24
25
26
27
28
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994, 1995, 1996.

###############################################################
## Version control history
###############################################################
## $Header$
## $Log$



## Revision 1.13  1996/08/16 08:24:31  peter
## Correctly chooses how to make a ps file using $REPTYPE.
##
## Revision 1.12  1996/08/15 16:47:47  peter
## DAE solution (experimental) included.
##
## Revision 1.11  1996/08/15 11:55:30  peter







>
>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright (c) P.J.Gawthrop, 1989, 1990, 1991, 1993, 1994, 1995, 1996.

###############################################################
## Version control history
###############################################################
## $Header$
## $Log$
## Revision 1.14  1996/08/16 14:52:24  peter
## Added two alternative view options - dview and pview.
##
## Revision 1.13  1996/08/16 08:24:31  peter
## Correctly chooses how to make a ps file using $REPTYPE.
##
## Revision 1.12  1996/08/15 16:47:47  peter
## DAE solution (experimental) included.
##
## Revision 1.11  1996/08/15 11:55:30  peter
123
124
125
126
127
128
129


130
131






132
133
134


135
136
137
138
139
140
141

# Classify the representation - needed for conversion route to postscript
case $2 in
	abg )
		REPTYPE='bg' ;;
	cbg )
		REPTYPE='bg' ;;


	odesol)
		REPTYPE='data' ;;






	daesol)
		REPTYPE='data' ;;
	sr)


		REPTYPE='data' ;;
	lmfr)
		REPTYPE='data' ;;
	lpfr)
		REPTYPE='data' ;;
	nyfr)
		REPTYPE='data' ;;







>
>
|

>
>
>
>
>
>
|


>
>







126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

# Classify the representation - needed for conversion route to postscript
case $2 in
	abg )
		REPTYPE='bg' ;;
	cbg )
		REPTYPE='bg' ;;
	odes)
		REPTYPE='data' ;;
	odeso)
		REPTYPE='data' ;;
	odess)
		REPTYPE='data' ;;
	odesso)
		REPTYPE='data' ;;
	daes)
		REPTYPE='data' ;;
	daeso)
		REPTYPE='data' ;;
	sr)
		REPTYPE='data' ;;
	sro)
		REPTYPE='data' ;;
	lmfr)
		REPTYPE='data' ;;
	lpfr)
		REPTYPE='data' ;;
	nyfr)
		REPTYPE='data' ;;
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
$1_sum.tex: $1_abg.pl
	abg2sum_pl2tex $1; latex_tidy $1_sum.tex

#Elementary system equations + definitions
$1_ese.r: $1_cbg.m
	   cbg2ese_m2r $1
$1_def.r: $1_ese.r
	touch $1_ese.r
$1_def.m: $1_def.r
	def_r2m $1; matlab_tidy $1_def.m;


#Differential-algebraic equations
$1_dae.r:	$1_ese.r $1_cr.r $1_sympar.r
	ese2dae_r $1; tidy $1_dae.r







|







253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
$1_sum.tex: $1_abg.pl
	abg2sum_pl2tex $1; latex_tidy $1_sum.tex

#Elementary system equations + definitions
$1_ese.r: $1_cbg.m
	   cbg2ese_m2r $1
$1_def.r: $1_ese.r
	touch $1_def.r
$1_def.m: $1_def.r
	def_r2m $1; matlab_tidy $1_def.m;


#Differential-algebraic equations
$1_dae.r:	$1_ese.r $1_cr.r $1_sympar.r
	ese2dae_r $1; tidy $1_dae.r
324
325
326
327
328
329
330


331
332


333
334










335
336
337
338
339
340
341
$1_tf.tex: $1_def.r $1_tf.r $1_sympar.r $1_simp.r
	tf_r2tex $1; latex_tidy $1_tf.tex


#Time responses
$1_sr.m: $1_dm.m $1_numpar.m $1_args.m $1_def.m
	dm2sr_m $1 '$ARGS'


$1_odesol.m: $1_ode.m $1_numpar.m $1_args.m $1_def.m $1_input.m
	ode2odesol_m $1 '$ARGS'


$1_daesol.m: $1_dae.m $1_numpar.m $1_args.m $1_def.m $1_input.m
	dae2daesol_m $1 '$ARGS'











#Frequency responses
$1_fr.m: $1_dm.m $1_numpar.m $1_args.m $1_def.m
	dm2fr_m $1 '$ARGS'
$1_lmfr.m: $1_fr.m
	touch $1_lmfr.m
$1_lpfr.m: $1_fr.m







>
>
|
|
>
>
|
|
>
>
>
>
>
>
>
>
>
>







337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
$1_tf.tex: $1_def.r $1_tf.r $1_sympar.r $1_simp.r
	tf_r2tex $1; latex_tidy $1_tf.tex


#Time responses
$1_sr.m: $1_dm.m $1_numpar.m $1_args.m $1_def.m
	dm2sr_m $1 '$ARGS'
$1_sro.m: $1_sr.m
	touch $1_sro.m
$1_odes.m: $1_ode.m $1_numpar.m $1_args.m $1_def.m $1_input.m
	ode2odes_m $1 '$ARGS'
$1_odeso.m: $1_odes.m
	touch $1_odeso.m
$1_daes.m: $1_dae.m $1_numpar.m $1_args.m $1_def.m $1_input.m
	dae2daes_m $1 '$ARGS'
$1_daeso.m: $1_daes.m
	touch $1_daeso.m

#Numerical steady states
$1_odess.m: $1_ode.m $1_numpar.m $1_args.m $1_def.m $1_input.m
	ode2odess_m $1 '$ARGS'

$1_odesso.m: $1_odess.m
	touch $1_odesso.m


#Frequency responses
$1_fr.m: $1_dm.m $1_numpar.m $1_args.m $1_def.m
	dm2fr_m $1 '$ARGS'
$1_lmfr.m: $1_fr.m
	touch $1_lmfr.m
$1_lpfr.m: $1_fr.m
385
386
387
388
389
390
391

392

393



394



395
396
397
398
399
400
401
402
403
404





405
406
407
408
409
410
411
#Create PostScript version of dvi file
$1_$2.ps: $1_$2.dvi
	echo Creating $1_$2.ps
	dvips -o $1_$2.ps $1_$2
endif

#Default view

$1_$2.view: $1_$2.ps

	echo Creating view of $1_$2



	ghostview $1_$2.ps&




#View a ps file
$1_$2.pview: $1_$2.ps
	echo Creating view of $1_$2
	ghostview $1_$2.ps&

#View a gdat file
$1_$2.dview: $1_$2.gdat
	echo Creating view of $1_$2
	gdat2view $1_$2 '$ARGS'&





	

#Report generation
$1_rep.tex: $1_sum.tex $1_dae.tex $1_lbl.txt $1_sympar.r $1_cr.r \
            $1_abg.ps
	echo Creating $1_rep.tex 
	make_report $1 > $1_rep.tex







>
|
>
|
>
>
>
|
>
>
>










>
>
>
>
>







412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
#Create PostScript version of dvi file
$1_$2.ps: $1_$2.dvi
	echo Creating $1_$2.ps
	dvips -o $1_$2.ps $1_$2
endif

#Default view
ifeq ($REPTYPE,bg)
$1_$2.view : $1_$2.pview
endif

ifeq ($REPTYPE,data)
$1_$2.view : $1_$2.dview
endif

ifeq ($REPTYPE,tex)
$1_$2.view : $1_$2.tview
endif

#View a ps file
$1_$2.pview: $1_$2.ps
	echo Creating view of $1_$2
	ghostview $1_$2.ps&

#View a gdat file
$1_$2.dview: $1_$2.gdat
	echo Creating view of $1_$2
	gdat2view $1_$2 '$ARGS'&
	
#View a tex file
$1_$2.tview: $1_$2.dvi
	echo Creating view of $1_$2
	xdvi $1_$2.dvi&
	

#Report generation
$1_rep.tex: $1_sum.tex $1_dae.tex $1_lbl.txt $1_sympar.r $1_cr.r \
            $1_abg.ps
	echo Creating $1_rep.tex 
	make_report $1 > $1_rep.tex

Modified mttroot/mtt/bin/trans/m/dm2sr.m from [3a20b68940] to [ef0adb9b22].

1
2
3
4
5
6

7
8
9
10
11
12



13
14
15
16
17
18
19
function sr = dm2sr(A,B,C,D,E,T,u0,x0);
% sr = dm2sr(A,B,C,D,E,T);
% Descriptor matrix to impulse response.
% NB At the moment - this assumes that E is unity .....
% A,B,C,D,E - descriptor matrices
% T vector of time points


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$



% %% Revision 1.3  1996/08/11 19:33:24  peter
% %% Replaced exp by expm - whoops!
% %%
% %% Revision 1.2  1996/08/11 10:37:40  peter
% %% Corrected mistake in step-response calculation.
% %%
% %% Revision 1.1  1996/08/11 09:42:40  peter
|
|




>






>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function [Y,X] = dm2sr(A,B,C,D,E,T,u0,x0);
% [Y,X] = dm2sr(A,B,C,D,E,T,u0,x0);
% Descriptor matrix to impulse response.
% NB At the moment - this assumes that E is unity .....
% A,B,C,D,E - descriptor matrices
% T vector of time points
% u0 input gain vector: u = u0*unit step.

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.4  1996/08/15 08:34:08  peter
% %% Added step gain (u0) and initial condition (x0)
% %%
% %% Revision 1.3  1996/08/11 19:33:24  peter
% %% Replaced exp by expm - whoops!
% %%
% %% Revision 1.2  1996/08/11 10:37:40  peter
% %% Corrected mistake in step-response calculation.
% %%
% %% Revision 1.1  1996/08/11 09:42:40  peter
37
38
39
40
41
42
43
44

45
46
47

48
49
50



51





52
if M>N
  T = T';
  N = M;
end;

one = eye(Nx);

sr = zeros(N,Ny);

i = 0;
for t = T'
  i=i+1;

  expAt = expm(A*t);
  SR = C*( ( A\(expAt-one) )*B*u0 + expAt*x0) + D*u0;
  sr(i,:) =SR';



end;













|
>



>
|
|
|
>
>
>
|
>
>
>
>
>

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
if M>N
  T = T';
  N = M;
end;

one = eye(Nx);

Y = zeros(N,Ny);
X = zeros(N,Nx);
i = 0;
for t = T'
  i=i+1;
  if Nx>0
    expAt = expm(A*t);
    x = ( A\(expAt-one) )*B*u0 + expAt*x0;
    X(i,:) = x';
    if Ny>0
      y = C*x + D*u0;
      Y(i,:) = y';
    end;
  elseif Ny>0
    y = D*u0;
    Y(i,:) = y';
  end;
end;

Modified mttroot/mtt/bin/trans/ode2odes_m from [75108a9087] to [1d1e1e88f4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

64




65

66
67
68
69
70
71
72

73
74
75
76
77
78
79
80
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2odesol_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.3  1996/08/16 06:36:03  peter
## Removed u from default arg list.
##
## Revision 1.2  1996/08/15 16:24:43  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.1  1996/08/15 11:56:38  peter
## Initial revision
##
###############################################################

echo Creating $1_odesol.m
rm -f ode2odesol_m.log

if [ "$2" = "" ]; 
then
  PARAMS='T=[0:0.1:10]; x0=zeros(nx,1);'
  echo Using default parameter $PARAMS
else
  PARAMS=$2;
fi

PARAMS="$PARAMS ;"


$MATRIX << EOF > ode2odesol_m.log

  [nx,ny,nu,nz,nyz] = $1_def;
  t=0;	%Just in case it appears in the parameter list.

  $PARAMS

  %Defaults
  if exist('T')==0
    T=[0:0.1:10]
  end;

  if exist('x0')==0
    x0 = zeros(nx,1);
  end;

  [n,m]=size(T);
  if m>n
    T=T';
  end;


x = lsode('$1_ode', x0, T);






i=0;
for tt=T'
  i=i+1;
  y(i,:) = $1_odeo(x(i,:),tt)';
end;

write_matrix([T,y], '$1_odesol');


EOF












|










>
>
>











|
|












|




















>
|
>
>
>
>

>
|
|
|
|
|
<
|
>








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

80
81
82
83
84
85
86
87
88
89
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: ode2odes_m

# Transforms descriptor matrix rep to step response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4  1996/08/16 13:04:46  peter
## Fixed problem with more than one output (y vector).
##
## Revision 1.3  1996/08/16 06:36:03  peter
## Removed u from default arg list.
##
## Revision 1.2  1996/08/15 16:24:43  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.1  1996/08/15 11:56:38  peter
## Initial revision
##
###############################################################

echo Creating $1_odes.m
rm -f ode2odes_m.log

if [ "$2" = "" ]; 
then
  PARAMS='T=[0:0.1:10]; x0=zeros(nx,1);'
  echo Using default parameter $PARAMS
else
  PARAMS=$2;
fi

PARAMS="$PARAMS ;"


$MATRIX << EOF > ode2odes_m.log

  [nx,ny,nu,nz,nyz] = $1_def;
  t=0;	%Just in case it appears in the parameter list.

  $PARAMS

  %Defaults
  if exist('T')==0
    T=[0:0.1:10]
  end;

  if exist('x0')==0
    x0 = zeros(nx,1);
  end;

  [n,m]=size(T);
  if m>n
    T=T';
  end;

if nx>0
  x = lsode('$1_ode', x0, T);
  write_matrix([T,x], '$1_odes');
else
  x = zeros(size(T));
end;

if ny>0
  i=0;
  for tt=T'
    i=i+1;
    y(i,:) = $1_odeo(x(i,:),tt)';
  end;

  write_matrix([T,y], '$1_odeso');
end;

EOF






Modified mttroot/mtt/bin/trans/sm2sr_m from [f93b47c81c] to [7599e65984].

12
13
14
15
16
17
18



19
20
21
22
23
24
25
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.7  1996/08/15 11:54:32  peter
## Now has optional initial condition.
##
## Revision 1.6  1996/08/14 09:15:02  peter
## Now encapsulates the data into an m file
## Name changed
##







>
>
>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  1996/08/15 16:23:39  peter
## Uses T in place of t to avoid name clash within function.
##
## Revision 1.7  1996/08/15 11:54:32  peter
## Now has optional initial condition.
##
## Revision 1.6  1996/08/14 09:15:02  peter
## Now encapsulates the data into an m file
## Name changed
##
37
38
39
40
41
42
43

44


45
46
47
48
49
50
51
##
## Revision 1.1  1996/08/11 09:45:46  peter
## Initial revision
##
###############################################################

echo Creating $1_sr.m

rm -f dm2sr_m.log



if [ "$2" = "" ]; 
then
  PARAMS='T=[0:0.1:10];u0=ones(nu,1);x0=zeros(nx,1);'
  echo Using default parameter $PARAMS
else
  PARAMS=$2;







>

>
>







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
##
## Revision 1.1  1996/08/11 09:45:46  peter
## Initial revision
##
###############################################################

echo Creating $1_sr.m
echo Creating $1_sro.m
rm -f dm2sr_m.log
rm -f $1_sr.m
rm -f $1_sro.m

if [ "$2" = "" ]; 
then
  PARAMS='T=[0:0.1:10];u0=ones(nu,1);x0=zeros(nx,1);'
  echo Using default parameter $PARAMS
else
  PARAMS=$2;
76
77
78
79
80
81
82
83
84




85

86
87
88

  [n,m]=size(T);
  if m>n
    T=T';
  end;

  [A,B,C,D,E] = $1_dm($1_numpar);
  y = dm2sr(A,B,C,D,E,T,u0,x0);





  write_matrix([T y], '$1_sr');


EOF








|

>
>
>
>
|
>



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

  [n,m]=size(T);
  if m>n
    T=T';
  end;

  [A,B,C,D,E] = $1_dm($1_numpar);
  [y,x] = dm2sr(A,B,C,D,E,T,u0,x0);

  if nx>0
    write_matrix([T x], '$1_sr');
  end;
  if ny>0
    write_matrix([T y], '$1_sro');
  end;

EOF


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]