Constant in a transfer function
40 次查看(过去 30 天)
显示 更早的评论
I have the transfer function
z + b
-----------------
z^2 - 1.5 z + 0.7
I want to write this to matlab so :
global b
h=tf([1 b],[1 -1.5 0.7],1)
However Matlab returns
1
-----------------
z^2 - 1.5 z + 0.7
How can I define it so that I can get the right answer?
1 个评论
Maria San Juan
2020-1-7
Hi! I had moreorless the same issue but with a plotting. After a few tries, this is the code I came up with. Not sure if can help you but maybe it´d help others in the future.
In my case, the exercise asked me to plot the response of a system to a step by changing the gain K from 0 to 5, 20 times. I mean, 20 "jumps" from 0 to 5. sys1 y sys2 were in serie while Hs was meant for the feeback.
s = tf('s');
Kvec= linspace(1,5,20);
t=0:0.1:10;
figure; hold on;
for i=1:20
k= Kvec(i);
sys1= k/s;
sys2= 10/(s*s +2*s+10);
Hs=1/(s+2);
Gs= sys1*sys2;
Ms= (Gs*Hs)/(1+Gs*Hs);
step(t,Ms);
end
By putting the "calculation" of the system within the for, I had no problems with declarating k because it took a value in each loop. And step works with tf butat the begining I tried declaring syms s k failing miserably. So by this way I relsolved the syms and the giving values to k problems.
Hope it helped somehow.
PS: Spanish girl, sorry for the mistakes. English is my second language.
采纳的回答
José Goulart
2011-1-23
Elias,
I think this is happening because you haven't defined a value to the b variable yet. For instance, if you try this instead:
global b;
b = 8;
h = tf([1 b],[1 -1.5 -.7],1)
Then you get
z + 8
-----------------
z^2 - 1.5 z - 0.7
So, apparently it is not possible to define a Transfer Function with symbolic parameters expecting that Matlab will resolve their values when you use it (I suppose this is what you wanted to do, am I right??). That is, you have to explicitly assign values to the variables before using them to construct a TF.
Hope that helps,
J.H. Goulart
0 个评论
更多回答(2 个)
Paulo Silva
2011-1-23
The tf function doesn't support what you want (I'm not 100% sure, someone could correct me), you must define the b value before passing it to tf, I tried using symbolic values and it didn't work, what you can do is define a constant value for b and compare the response to usual input signals like the step and impulse, you can even use bode(h) and see the diferences.
clear clf clc figh=figure(1); axh1=subplot(2,1,1,'Parent',figh); hold(axh1,'on'); axh2=subplot(2,1,2,'Parent',figh); hold(axh2,'on'); for b=1:5 h=tf([1 b],[1 -1.5 0.7],1); step(axh1,h) impulse(axh2,h) end legend(axh1,'b=1','b=2','b=3','b=4','b=5') legend(axh2,'b=1','b=2','b=3','b=4','b=5')
0 个评论
Elias
2011-1-23
1 个评论
Paulo Silva
2011-1-23
b must be obtained experimentally or calculated using some textbook formulas, I'm sure you can find the formulas and examples on these books
Franklin G.F., Powell J.D., Workman M.L., “Digital Control of Dynamic Systems”, 3rd Edition, Addison-Wesley, 1998.
K. J. Astrom, and H. Winttenmark, “Computer-controlled systems: theory and design”, 3ª ed., Prentice-Hall, 1998.
K. Ogata, “Discrete Time Control Systems”, Prentice-Hall, 1994.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Control System Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!