Undefined function 'Poles' for input arguments of type 'double'.

4 次查看(过去 30 天)
I run into the problem where my code produces the error message as stated above. I've searched around and 1 possible problem has something to do with my file path. I have since fixed that but I am still receiving the same problem. Am hoping somebody could help point out my error in the code. I am trying to apply Lyapunov stability analysis to my state space system and plot a phase portrait with the program below.
Any help is much appreciated! Thanks in advance.
% Using Lyapunov analysis, assess the stability properties of the
% system; any case will do since the A matrix is identical for all
% input/ouput cases, the stability condition does not change.
% Check your results via eigenvalue analysis. Plot the phase portraits to
% reinforce your results.
% Values used from chapter 1.
% Mass values
m1 = 1;
m2 = 2;
m3 = 3;
% Spring Coefficients
k1 = 1;
k2 = 2;
k3 = 3;
k4 = 4;
% Damping Coefficients
c1 = 1;
c2 = 2;
c3 = 3;
c4 = 4;
% A, B, C and D matrix generated from chapter 1.
A = [0 0 0 1 0 0;
0 0 0 0 1 0;
0 0 0 0 0 1;
((-1)*((k1+k2)/m1)) (k2/m1) 0 ((-1)*((c1+c2)/m1)) (c2/m1) 0;
(k2/m2) ((-1)*((k2+k3)/m2)) (k3/m3) (c2/m2) ((-1)*((c2+c3)/m2)) (c3/m2);
0 (k3/m3) ((-1)*((k3+k4)/m3)) 0 (c3/m3) ((-1)*((c3+c4)/m3))];
B = [0 0 0;
0 0 0;
0 0 0;
(1/m1) 0 0;
0 (1/m2) 0;
0 0 (1/m3)];
C = [1 0 0 0 0 0;
0 1 0 0 0 0;
0 0 1 0 0 0];
D = [0 0 0;
0 0 0;
0 0 0];
sys_1 = ss(A,B,C,D);
X0(101,:);
if (real(Poles(1))==0 | real(Poles(2))==0) % lyap will fail
if (real(Poles(1)) <=0 | real(Poles(2)) <=0)
disp('System is marginally stable');
else
disp('System is unstable');
end
else % lyap succeeds
Q = eye(6); % Given positive definite matrix
P = lyap(A',Q); % Solve for P
pm1 = det(P(1,1)); % Sylvester's method to see if P is positive definite
pm2 = det(P(1:6,1:6));
if (pm1>0 & pm2>0)
disp('System is asymptotically stable.');
else
disp('System is unstable');
end
end
figure;
plot(Xo(:,1),Xo(:,2),'k');
axis([-1.5 -1.5 -2 1]);
set(gca,'Fontsize',18);
xlabel('\itx_1(rad)');
ylabel('\itx_2 (rad/s)');

采纳的回答

Paul
Paul 2021-11-16
From the way the code is written it looks like Poles is supposed to be a variable. But the code never actually computes Poles. So Matlab can't find a variable called Poles, so it next assumes it's a function. But Matlab doesn't have a function called Poles and the error results. I suspect that you meant to do
Poles = pole(sys)
% doc pole % for more information
before executing the if statement. Of course, Poles will have six elements because the system is 6th order.
Also, you might want to take another look at that if logic. I don't know exactly what it's trying to do, but it looks peculiar.
  1 个评论
Justin Goh
Justin Goh 2021-11-16
Thank you Paul. I feel like a fool for not realizing that. I managed to fix my program and it now does not produce that problem.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Computations 的更多信息

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by