Please help. The first input argument of the "tf" command cannot be a string.
Afficher commentaires plus anciens
clear, clc
G1=tf([1],[1 0 5])
G2=tf([10],[1])
G3=tf('k')
G4=tf([1 1],[1 0])
H1=tf([1 0],[1])
H2=tf([1 5],[1])
TR1=feedback(G1,H1,-1)
T1=series(TR1,G2)
TR2=feedback(T1,H2,-1)
T2=series(TR2*G3)
Error using tf
Invalid syntax. The first input argument of the "tf" command cannot be a string.
9 commentaires
Dyuman Joshi
le 23 Nov 2023
'k' is not an accepted variable to define a transfer function variable.
Melissa
le 23 Nov 2023
Modifié(e) : Walter Roberson
le 23 Nov 2023
Walter Roberson
le 23 Nov 2023
In particular, when you use tf() with just a single character parameter, the only two supported characters are 's' and 'z' . The s and p and ^-1 possibilities only apply if you use 'Variable' option.
Note: It is not possible to use the Control System Toolbox to create a transfer function that has an undetermined parameter. You cannot use Control System to construct something along the lines of
s^2 + k*s + 1
-------------
5*s^3 - 3 * s + 2
where k is an undetermined coefficient.
The closest that Control System Toolbox has to that, is the possibility of putting in tuning variables. Tuning variables always have a particular value at any one time, but the code is constructed to make it easy to change the value (including changing it under program control.) No facility to "reason" about the form of the equations is available.
If you have a system like the one I showed above, with an undetermined coefficient that is not the s or z, then you need to use the Symbolic Toolbox
Walter Roberson
le 23 Nov 2023
T2=series(TR2*G3)
series constructs control systems in series. Each system to be placed in series must be given as a seperate parameter, such as
T2=series(TR2,G3)
Walter Roberson
le 23 Nov 2023
It is not clear to us what you are trying to do. Do you want the user to enter coefficients of a transfer function? If so then it would be common to prompt for numerator and denominator separately, something like
G3N = input('enter numerator coefficients: ');
G3D = input('enter denominiator coefficients: ');
G3 = tf(G3N, G3D);
I am not certain what you want to do with respect to:
G3 = tf('s')
The usual approach is something like this —
s = tf('s');
then:
G1 = tf([1],[1 0 5])
G2 = tf([10],[1])
G3 = s
G4 = tf([1 1],[1 0])
H1 = tf([1 0],[1])
H2 = tf([1 5],[1])
TR1 = feedback(G1,H1,-1)
T1 = series(TR1,G2)
TR2 = feedback(T1,H2,-1)
T2 = series(TR2,G3)
figure
stepplot(T2)
grid
figure
bodeplot(T2)
grid
I added the plots out of interest.
.
Melissa
le 23 Nov 2023
Walter Roberson
le 24 Nov 2023
As I indicated earlier, the Control System Toolbox has absolutely no ability to work with variables with unknown value. I discussed what is available in https://www.mathworks.com/matlabcentral/answers/305339-how-to-create-a-transfer-function-with-gain-k#comment_395202
Réponses (3)
Besides of using 'k' for tf, there is another syntax error in T2. See the corrected core here:
clear, clc
G1=tf([1],[1 0 5])
G2=tf([10],[1])
G3=tf('s')
G4=tf([1 1],[1 0])
H1=tf([1 0],[1])
H2=tf([1 5],[1])
TR1=feedback(G1,H1,-1)
T1=series(TR1,G2)
TR2=feedback(T1,H2,-1)
T2=series(TR2,G3) % T2=series(TR2*G3) leads to "Not enough input arguments"
1 commentaire
Melissa
le 23 Nov 2023
Sulaymon Eshkabilov
le 23 Nov 2023
If you want to use a user prompt then it should be in this way (Note that just numerical input prompt won't work):
Try:
G3N = 1 1
G3D = 1 2 3
enter numerator coefficients: 1 1
enter denominiator coefficients: 1 2 3
G3N = input('enter numerator coefficients: ', 's' );
G3D = input('enter denominiator coefficients: ', 's');
G3 = tf(str2num(G3N), str2num(G3D))
G3 =
s + 1
-------------
s^2 + 2 s + 3
Hi @Melissa
Variable K doesn't a specific value, I want multiply K other variables like TR2...
From the root locus, it appears that the closed-loop system system will be stable for any value of the gain parameter K.
G1 = tf([1],[1 0 5]);
G2 = tf([10],[1]);
% G3 = tf('k') % <-- it seems that you want to multiply k with TR2 at the end
H1 = tf([1 0],[1]);
H2 = tf([1 5],[1]);
TR1 = feedback(G1, H1);
T1 = series(TR1, G2);
rlocus(T1*H2)
% T2 = series(TR2*G3)
Catégories
En savoir plus sur Text Data Preparation dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


