|
9 | 9 | % See also c2d. |
10 | 10 | % |
11 | 11 | % Copyright © 2021 Tamas Kis |
12 | | -% Last Update: 2021-10-09 |
| 12 | +% Last Update: 2022-04-20 |
13 | 13 | % Website: https://tamaskis.github.io |
14 | 14 | |
15 | 15 | % |
16 | 16 | % TECHNICAL DOCUMENTATION: |
17 | 17 | % https://tamaskis.github.io/documentation/Continuous_to_Discrete_Transfer_Function_Transformation_Using_the_Euler_Methods.pdf |
18 | 18 | % |
19 | | -% REFERENCES: |
20 | | -% [1] Franklin et. al., "Digital Control of Dynamic Systems", 3rd Ed. |
21 | | -% [2] https://www.mathworks.com/matlabcentral/answers/96275-how-can-i-convert-a-transfer-function-object-from-the-control-system-toolbox-into-a-symbolic-object |
22 | | -% [3] https://gist.github.com/maruta/1035254 |
23 | | -% [4] https://www.mathworks.com/matlabcentral/fileexchange/27302-syms-to-tf-conversion |
| 19 | +% REQUIREMENTS: |
| 20 | +% • Control System Toolbox |
| 21 | +% • Symbolic Math Toolbox |
24 | 22 | % |
25 | 23 | %-------------------------------------------------------------------------- |
26 | 24 | % |
|
30 | 28 | % Hs - (1×1 tf or zpk) continous transfer function |
31 | 29 | % T - (1×1 double) sampling period |
32 | 30 | % type - (char) 'forward' or 'backward' |
33 | | -% output - (OPTIONAL) (char) specifies output type ('tf' or 'zpk') |
| 31 | +% output - (char) (OPTIONAL) specifies output type ('tf' or 'zpk') |
34 | 32 | % |
35 | 33 | % ------- |
36 | 34 | % OUTPUT: |
|
40 | 38 | %========================================================================== |
41 | 39 | function Hz = c2d_euler(Hs,T,type,output) |
42 | 40 |
|
43 | | - % ---------------------------------------------------- |
44 | | - % Sets unspecified parameters to their default values. |
45 | | - % ---------------------------------------------------- |
46 | | - |
47 | | - % defaults "output" to 'tf' |
| 41 | + % defaults "output" to 'tf' if not input |
48 | 42 | if (nargin < 4) || isempty(output) |
49 | 43 | output = 'tf'; |
50 | 44 | end |
51 | 45 |
|
52 | | - % -------------------------------------- |
53 | | - % Continuous-to-discrete transformation. |
54 | | - % -------------------------------------- |
55 | | - |
56 | 46 | % symbolic variable for z; |
57 | 47 | z = sym('z'); |
58 | 48 |
|
|
75 | 65 | [sym_num,sym_den] = numden(Hz); |
76 | 66 | num = sym2poly(sym_num); |
77 | 67 | den = sym2poly(sym_den); |
78 | | - |
| 68 | + |
79 | 69 | % creates discrete transfer function model |
80 | 70 | Hz = tf(num,den,T); |
81 | 71 |
|
|
0 commit comments