Please help. The first input argument of the "tf" command cannot be a string.

조회 수: 6 (최근 30일)
Melissa
Melissa 2023년 11월 23일
댓글: Walter Roberson 2023년 11월 24일
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
Melissa
Melissa 2023년 11월 23일
Variable K doesn't a specific value, I want multiply K other variables like TR2
It's a unknown variable that can be replace with X or other letter
Walter Roberson
Walter Roberson 2023년 11월 24일
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

댓글을 달려면 로그인하십시오.

답변 (3개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 11월 23일
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])
G1 = 1 ------- s^2 + 5 Continuous-time transfer function.
G2=tf([10],[1])
G2 = 10 Static gain.
G3=tf('s')
G3 = s Continuous-time transfer function.
G4=tf([1 1],[1 0])
G4 = s + 1 ----- s Continuous-time transfer function.
H1=tf([1 0],[1])
H1 = s Continuous-time transfer function.
H2=tf([1 5],[1])
H2 = s + 5 Continuous-time transfer function.
TR1=feedback(G1,H1,-1)
TR1 = 1 ----------- s^2 + s + 5 Continuous-time transfer function.
T1=series(TR1,G2)
T1 = 10 ----------- s^2 + s + 5 Continuous-time transfer function.
TR2=feedback(T1,H2,-1)
TR2 = 10 --------------- s^2 + 11 s + 55 Continuous-time transfer function.
T2=series(TR2,G3) % T2=series(TR2*G3) leads to "Not enough input arguments"
T2 = 10 s --------------- s^2 + 11 s + 55 Continuous-time transfer function.

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 11월 23일
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

Sam Chak
Sam Chak 2023년 11월 24일
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)

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by