error using eig, input matrix contains nan or inf

조회 수: 13 (최근 30일)
Harleen Kaur
Harleen Kaur 2019년 5월 6일
댓글: Harleen Kaur 2019년 5월 6일
A=[-9.4375 0 0 0 6.9375;0 -162.5385 0 -1.218*10^(-5) 0;0 160.038 -2.5 -1.218*10^(-5) 0;2.5 -32007.7 0 -2.4975 0;6.9375 0 0 2.5 -9.4375];
C=[1 0 0 0 0;0 0 0 1 0;0 0 0 0 1;0 0 0 0 0;0 0 0 0 0];
% Continuous-time Model
nx=5; nc=5;
% Clear Old Variables
yalmip('clear'); C1=[]; C2=[];
% Define Variables
Z0=sdpvar(nx); Z1=sdpvar(nc,nx); % Z0 > 0
C1=[0 <= Z0];
% (Z0A-Z1C)'+(Z0A-Z1C) + I < 0
C2=[(Z0*A-Z1*C)+(Z0*A-Z1*C)' + eye(nx) <= 0];
% Define Constraints and Objective
Constraints=[C1,C2]; Objective=[];
% Determine Feasibility
options = sdpsettings('verbose',0,'solver','mosek'); sol = optimize(Constraints,Objective,options);
if sol.problem == 0 % problem is feasible
Z0feas=value(Z0); Z1feas=value(Z1); KKfeas=Z1feas/Z0feas
eig(A-C*KKfeas)
elseif sol.problem == 1 % problem is infeasible
disp('Infeasible Problem'); else
disp('Hmm, something went wrong!'); sol.info; pause
end
In this code I am getting an error, 'error using eig, matrix contains NaN or inf'.
My C matrix was 3*5, but I had to change to 5*5 as I should give same dimensions as of A. But because of 0's I am getting an error and can't take out eigen values.
Any help would be appreciated
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 5월 6일
You do not appear to be pulling a value for Z0 out of sol, so I would suspect it might still be just the general variable you defined.
Note that yalmip is a third party package, and most of the volunteers will not be familiar with it.
Harleen Kaur
Harleen Kaur 2019년 5월 6일
Yes, got it. Thank you.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by