Error using ^ for control systems related functions
2 views (last 30 days)
Show older comments
Mohammad Aliuddin Mohamed Anwer
on 3 Oct 2023
Commented: Sam Chak
on 3 Oct 2023
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 Comments
Accepted Answer
Walter Roberson
on 3 Oct 2023
you have supplied your own poly.m which is interfering with using the matlab poly() function
More Answers (1)
Sam Chak
on 3 Oct 2023
Hi Aliuddin,
If you want to get the transfer function directly, then use this syntax:
tfsys = tf(ss(A,B,C,D))
3 Comments
See Also
Categories
Find more on Get Started with Control System Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!