Error using ^ for control systems related functions
2 次查看(过去 30 天)
显示 更早的评论
I have a simple transfer function as shown below.
>> P = tf(8,[1 8])
P =
8
-----
s + 8
Continuous-time transfer function.
However when I attempt to use the minreal() function I encounter this error:
>> minreal(P)
Error using DynamicSystem/minreal
Incorrect dimensions for raising a matrix to a power. Check that the matrix is
square and the power is a scalar. To operate on each element of the matrix
individually, use POWER (.^) for elementwise power.
This error is not limited to the transfer function above but to more complex transfer functions as well. Additionally, I have encountered this issue when running other codes as well, notably converting state space models to a transfer function shown below.
>> A = [-1.5,-2;1,0];
B = [0.5;0];
C = [0,1];
D = 0;
sys = ss(A,B,C,D)
sys =
A =
x1 x2
x1 -1.5 -2
x2 1 0
B =
u1
x1 0.5
x2 0
C =
x1 x2
y1 0 1
D =
u1
y1 0
Continuous-time state-space model.
>> sys_as_tf = tf(sys)
Error using DynamicSystem/tf
Incorrect dimensions for raising a matrix to a power. Check that the matrix is
square and the power is a scalar. To operate on each element of the matrix
individually, use POWER (.^) for elementwise power.
Similarly when I attempt to convert a state space model to a transfer function using ss2tf I encounter the same error as well.
>> A = [-1.5,-2;1,0];
B = [0.5;0];
C = [0,1];
D = 0;
>> tfsys = ss2tf(A,B,C,D);
Error using ^
Incorrect dimensions for raising a matrix to a power. Check that the matrix is
square and the power is a scalar. To operate on each element of the matrix
individually, use POWER (.^) for elementwise power.
Error in poly (line 2)
sqrd=x^2+y;
Error in ss2tf (line 30)
den = poly(p);
I have tried reinstalling the toolbox, reinstalling MATLAB r2023a and even installed version r2022a but I am not able to resolve this error regardless of what I do. I assume it may have something to do with the laptop I am using as I do not face these issues on MATLAB Online but I am unsure of what specifically could be causing these issues locally in my device.
0 个评论
采纳的回答
Walter Roberson
2023-10-3
you have supplied your own poly.m which is interfering with using the matlab poly() function
更多回答(1 个)
Sam Chak
2023-10-3
Hi Aliuddin,
If you want to get the transfer function directly, then use this syntax:
tfsys = tf(ss(A,B,C,D))
3 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Control System Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!