why is the zpk function not producing the transfer function in MATLAB?
9 ビュー (過去 30 日間)
古いコメントを表示
Hello guys,
I am trying to use the zpk function, where I input the zeros, poles and gain and it should return the factored form of the transfer function but it is not giving me that output. The code I used is below with the output I am getting from zpk.
a = [2,5,9,5,3];
b = [5,45,2,1,1];
[zer,pol,t] = zplane(a,b);
z = zeros(1,4);
p = zeros(1,4);
%disp('Zeros of the Transfer function are: ');
for i = 1:4
X = ['(',num2str(zer.XData(i)),',',num2str(zer.YData(i)),')'];
z(i) = zer.XData(i) + 1i*zer.YData(i);
%disp(X)
end
%disp('Poles of the transfer function are: ');
for i = 1:(length(b)-1)
X = ['(',num2str(pol.XData(i)),',',num2str(pol.YData(i)),')'];
p(i) = pol.XData(i) + 1i*pol.YData(i);
%disp(X);
end
%disp(z);
G = zpk([z],[p],1);
disp(G);
Output:
zpk with properties:
Z: {[4×1 double]}
P: {[4×1 double]}
K: 1
DisplayFormat: 'roots'
Variable: 's'
IODelay: 0
InputDelay: 0
OutputDelay: 0
Ts: 0
TimeUnit: 'seconds'
InputName: {''}
InputUnit: {''}
InputGroup: [1×1 struct]
OutputName: {''}
OutputUnit: {''}
OutputGroup: [1×1 struct]
Notes: [0×1 string]
UserData: []
Name: ''
SamplingGrid: [1×1 struct]
0 件のコメント
採用された回答
Star Strider
2022 年 2 月 11 日
Remove the closing parentheses in the ‘G’ assignment to see the result as a sort of ‘prettyprint’ output:
a = [2,5,9,5,3];
b = [5,45,2,1,1];
[zer,pol,t] = zplane(a,b);
z = zeros(1,4);
p = zeros(1,4);
%disp('Zeros of the Transfer function are: ');
for i = 1:4
X = ['(',num2str(zer.XData(i)),',',num2str(zer.YData(i)),')'];
z(i) = zer.XData(i) + 1i*zer.YData(i);
%disp(X)
end
%disp('Poles of the transfer function are: ');
for i = 1:(length(b)-1)
X = ['(',num2str(pol.XData(i)),',',num2str(pol.YData(i)),')'];
p(i) = pol.XData(i) + 1i*pol.YData(i);
%disp(X);
end
%disp(z);
G = zpk([z],[p],1)
Zv = G.Z{:}
Pv = G.P{:}
Kv = G.K
disp(G)
.
6 件のコメント
Star Strider
2022 年 2 月 12 日
As always, my pleasure!
It might be possible to add that as a format option for the ‘prettyprint’ output. The best way to approach that is to Contact Support and request that as an enhancement.
その他の回答 (1 件)
Paul
2022 年 2 月 11 日
What output is expected? It looks like zpk() is returning a zpk object with poles and zeros at locations shown on the plot.
a = [2,5,9,5,3];
b = [5,45,2,1,1];
[zer,pol,t] = zplane(a,b);
z = zeros(1,4);
p = zeros(1,4);
%disp('Zeros of the Transfer function are: ');
for i = 1:4
X = ['(',num2str(zer.XData(i)),',',num2str(zer.YData(i)),')'];
z(i) = zer.XData(i) + 1i*zer.YData(i);
%disp(X)
end
%disp('Poles of the transfer function are: ');
for i = 1:(length(b)-1)
X = ['(',num2str(pol.XData(i)),',',num2str(pol.YData(i)),')'];
p(i) = pol.XData(i) + 1i*pol.YData(i);
%disp(X);
end
%disp(z);
G = zpk([z],[p],1);
G
G.Z{:}
G.P{:}
The order of the inputs to zplane are zplane(numerator,denominator). Is a really the numerator and b really the denominator? Only asking because the typical naming convention in Matlab is that b is the numerator and a is the denominator. Will continue assuing a is the num and b is the den, but I suggest rechecking that.
If the goal is just to get the zpk representation with poles and zeros governed by a and b with a gain of k=1, that code seems like a really complicated way to go about it. Could just do
G1 = zpk(roots(a),roots(b),1)
However, if the goal is get the zpk representation of the transfer function a(s)/b(s), then there is an error because the gain is not unity
G2 = zpk(tf(a,b))
Note the gain k = 0.4.
Finally, the code is uzing zplane which suggests these are poles and zeros of a discrete time transfer function. As can be seen, zpk returns a continuous time model unless the sample time argument is provided.
G3 = zpk(tf(a,b,-1))
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

