What calculation is done to find the gains (k) of the zpk function?

8 views (last 30 days)
State space matrix:
A = [ -0.669951646484827 1.28424762631945e-09 0.011224152177422 -0.137266467613442 0 8.3380759857086e-07;
1 0 0 0 0 0;
-15.5796093146461 -9.77564302835082 -0.0172201697024891 0.0437085492873758 0 -9.43217074987179e-05;
195.456682375095 -0.779222433532193 -0.0745486085894737 -0.730188697017893 0 -0.00127843959431113;
0 -2.89356048753657e-05 0.996838168810935 0.0794585752910095 0 0;
0 -197.035459421598 -0.0794585753231511 0.996838168812305 0 0];
B = [ -36.5034154566994;
0;
3.76413630113738;
-25.9051875864034;
0;
0];
C =[ 1 0 0 0 0 0;
195.456682375095 -0.779222433532193 -0.0745486085894737 -0.730188697017893 0 -0.00127843959431113];
D = [ 0;
-25.9051875864034];
[z,p,k] = ss2zp(A,B,C,D)
z =
Column 1
-0.62671948453317 + 0i
-0.0217530033855665 + 0i
-0.000365798857384335 + 0i
-5.92556062974436e-09 + 0i
5.92549129068837e-09 + 0i
Inf + 0i
Column 2
0 + 0i
-276.100495151319 + 0i
-0.0085919008871075 + 0.0722792555820489i
-0.0085919008871075 - 0.0722792555820489i
-0.00147218583594221 + 0i
-2.50275860753844e-15 + 0i
p =
0 + 0i
-0.696733151596068 + 5.19575335398669i
-0.696733151596068 - 5.19575335398669i
-0.0116313338403144 + 0.0872215466769184i
-0.0116313338403144 - 0.0872215466769184i
-0.000631542332441605 + 0i
k =
-36.5034154566994
-25.9051875864034
How is the calculation done to find the earnings: -36.5034154566994 and -25.9051875864034?

Answers (2)

Star Strider
Star Strider on 15 Oct 2024
I am not certain that it is documented anywhere (I cannot find it), however it appears to be the coefficient of the highest-order component of the numerator of the transfer function representation.
Example —
A = [ -0.669951646484827 1.28424762631945e-09 0.011224152177422 -0.137266467613442 0 8.3380759857086e-07;
1 0 0 0 0 0;
-15.5796093146461 -9.77564302835082 -0.0172201697024891 0.0437085492873758 0 -9.43217074987179e-05;
195.456682375095 -0.779222433532193 -0.0745486085894737 -0.730188697017893 0 -0.00127843959431113;
0 -2.89356048753657e-05 0.996838168810935 0.0794585752910095 0 0;
0 -197.035459421598 -0.0794585753231511 0.996838168812305 0 0];
B = [ -36.5034154566994;
0;
3.76413630113738;
-25.9051875864034;
0;
0];
C =[ 1 0 0 0 0 0;
195.456682375095 -0.779222433532193 -0.0745486085894737 -0.730188697017893 0 -0.00127843959431113];
D = [ 0;
-25.9051875864034];
[z,p,k] = ss2zp(A,B,C,D)
z =
1.0e+02 * -0.0063 + 0.0000i 0.0000 + 0.0000i -0.0002 + 0.0000i -2.7610 + 0.0000i -0.0000 + 0.0000i -0.0001 + 0.0007i -0.0000 + 0.0000i -0.0001 - 0.0007i 0.0000 + 0.0000i -0.0000 + 0.0000i Inf + 0.0000i -0.0000 + 0.0000i
p =
0.0000 + 0.0000i -0.6967 + 5.1958i -0.6967 - 5.1958i -0.0116 + 0.0872i -0.0116 - 0.0872i -0.0006 + 0.0000i
k = 2×1
-36.5034 -25.9052
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
format shortG
[n,d] = ss2tf(A,B,C,D)
n = 2×7
1.0e+00 * 0 -36.503 -23.685 -0.50631 -0.00018204 -7.2022e-18 9.5167e-21 -25.905 -7152.9 -133.57 -38.076 -0.055788 -4.8735e-16 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
d = 1×7
1 1.4174 27.522 0.66746 0.2132 0.00013438 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
.
  4 Comments
Star Strider
Star Strider on 15 Oct 2024
It is however you calculated it!
We have no idea what you are doing or how you designed that system.

Sign in to comment.


Sam Chak
Sam Chak on 15 Oct 2024
Short Answer:
Due to your specific state-space configuration, k(1) is derived from the first element of the input matrix , while k(2) is derived from the second element of the direct matrix .
format long g
A = [ -0.669951646484827 1.28424762631945e-09 0.011224152177422 -0.137266467613442 0 8.3380759857086e-07;
1 0 0 0 0 0;
-15.5796093146461 -9.77564302835082 -0.0172201697024891 0.0437085492873758 0 -9.43217074987179e-05;
195.456682375095 -0.779222433532193 -0.0745486085894737 -0.730188697017893 0 -0.00127843959431113;
0 -2.89356048753657e-05 0.996838168810935 0.0794585752910095 0 0;
0 -197.035459421598 -0.0794585753231511 0.996838168812305 0 0];
B = [ -36.5034154566994;
0;
3.76413630113738;
-25.9051875864034;
0;
0];
C = [ 1 0 0 0 0 0;
195.456682375095 -0.779222433532193 -0.0745486085894737 -0.730188697017893 0 -0.00127843959431113];
D = [ 0;
-25.9051875864034];
sys = ss(A, B, C, D);
k1 = B(1)
k1 =
-36.5034154566994
k2 = D(2)
k2 =
-25.9051875864034
Long Answer:
MATLAB does not show the steps to obtain the solution; it typically provides only the numerical solution in most cases.
The state-space representation must be converted to transfer matrix form using the following formula, which can be found in any Modern Control Theory textbook:
.
In this equation, the transfer matrix relates the number of outputs to the number of inputs . The output matrix indicates that there are two outputs, while the input matrix indicates that there is only one input. Consequently, the transfer matrix will consist of two transfer functions.
The gain vector k obtained from the zpk() command is an array of the coefficients of the highest degree of the numerator in each transfer function.
G = tf(sys)
G = From input to output... -36.5 s^4 - 23.68 s^3 - 0.5063 s^2 - 0.000182 s + 3.613e-20 1: --------------------------------------------------------------- s^5 + 1.417 s^4 + 27.52 s^3 + 0.6675 s^2 + 0.2132 s + 0.0001344 -25.91 s^5 - 7153 s^4 - 133.6 s^3 - 38.08 s^2 - 0.05579 s - 2.377e-18 2: --------------------------------------------------------------------- s^5 + 1.417 s^4 + 27.52 s^3 + 0.6675 s^2 + 0.2132 s + 0.0001344 Continuous-time transfer function.
[num, den] = tfdata(G, 'v')
num = 2x1 cell array
{[ 0 -36.5034154566995 -23.6848135464053 -0.506311190296269 -0.000182040605087803 3.61253687043047e-20]} {[-25.9051875864034 -7152.91840645244 -133.573644890081 -38.0755416738836 -0.0557875976251336 -2.376582946259e-18]}
den = 2x1 cell array
{[1 1.41736051320521 27.5223433539825 0.667458527478527 0.213195050723291 0.000134382418944796]} {[1 1.41736051320521 27.5223433539825 0.667458527478527 0.213195050723291 0.000134382418944796]}
%% Extract the data from the cell array
k1 = num{1}(2)
k1 =
-36.5034154566995
k2 = num{2}(1)
k2 =
-25.9051875864034
  7 Comments
Rafaella Barrêto Campos
Rafaella Barrêto Campos on 15 Oct 2024
X_trim =
0.0156566822191464
0.0795424262493709
196.412468864823
15.6561280499959
0
-3048
U_trim =
-0.091567106993385
[A,B,C,D]=linmod(modelName,X_trim,U_trim)
A =
Columns 1 through 2
-0.669951646484827 1.28424762631945e-09
1 0
-15.5796093146461 -9.77564302835082
195.456682375095 -0.779222433532193
0 -2.89356048753657e-05
0 -197.035459421598
Columns 3 through 4
0.011224152177422 -0.137266467613442
0 0
-0.0172201697024891 0.0437085492873758
-0.0745486085894737 -0.730188697017893
0.996838168810935 0.0794585752910095
-0.0794585753231511 0.996838168812305
Columns 5 through 6
0 8.3380759857086e-07
0 0
0 -9.43217074987179e-05
0 -0.00127843959431113
0 0
0 0
B =
-36.5034154566994
0
3.76413630113738
-25.9051875864034
0
0
C =
Columns 1 through 2
1 0
195.456682375095 -0.779222433532193
Columns 3 through 4
0 0
-0.0745486085894737 -0.730188697017893
Columns 5 through 6
0 0
0 -0.00127843959431113
D =
0
-25.9051875864034
How is matrix B calculated?
Sam Chak
Sam Chak on 16 Oct 2024
Your new query regarding the computation of matrix appears to be unrelated to your original question about how to obtain the gain k, which has been adequately explained above by @Star Strider and me.
Since the technical explanations have been provided, please accept the answer that you find most satisfactory and vote for other helpful responses. You may then continue the discussion in your thread titled "function zpk and linmod," as the "short" answer can be found there.
Accepting answers to questions that have been adequately addressed, rather than leaving their status 'open,' will increase the likelihood of unanswered question receiving favorable responses from other users or experts.

Sign in to comment.

Categories

Find more on Control Systems in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!