Constant in a transfer function

65 ビュー (過去 30 日間)
Elias
Elias 2011 年 1 月 23 日
コメント済み: Maria San Juan 2020 年 1 月 7 日
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
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
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

その他の回答 (2 件)

Paulo Silva
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')

Elias
Elias 2011 年 1 月 23 日
Thank you for your answers.
The project I have is to design a controller in relation to b. As I understand b is not supposed to take any values. I tried to define it as a variable too (syms b) but that does not work either.
Any ideas are appreciated!
  1 件のコメント
Paulo Silva
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.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by