Error: The "A" matrix must be a numeric array with no Inf's or NaN's.
조회 수: 38 (최근 30일)
이전 댓글 표시
coder.extrinsic("testcon2dis")
I_2 = eye(2);
O_2 = zeros(2);
Ac_xy = [O_2 -(1/Lfilter)*I_2 O_2; (1/Cfilter)*I_2 O_2 -(1/Cfilter)*I_2; O_2 O_2 w* J];
Bc_xy = [(Vdc/Lfilter)*I_2 O_2 O_2]' * Tr;
Cxy = [I_2 O_2 O_2; O_2 I_2 O_2];
[A, B] = testcon2dis(Ac_xy, Bc_xy, Cxy, Ts);
%%%%%%%%%%%%%%%% Below is the testcon2dis%%%%%%%%%%%%%%%%
function[A,B] = testcon2dis(Ac_xy,Bc_xy,Cxy,Ts)
ct_sys = ss(Ac_xy,Bc_xy,Cxy,[]);
dt_sys = c2d(ct_sys,Ts);
A = dt_sys.a;
B = dt_sys.b;
end
%%%%%%%%%%%%%%%%%%%%%%% Error message
Error:The "A" matrix must be a numeric array with no Inf's or NaN's.
Error in ss.ss.m (line 290)
throw(ME)
Error in testcon2dis.m (line 2)
Error in 'MPC_3Phase_Inverter/MATLAB Function1' (line 31)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Any suggestions I tried calling the A marix as a double or zeros to give it sizes but still got new errors doesn't work(this block of code is used in a matlab function block simulink)
%%%%%%%%%%%%%%%%%%%%% Error message calling A as a double or zeros(6,6)%%%%%%%%%%%%%%%
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
> In MPC_Matrices_l (line 69)
Error:Matrix must be positive definite.
Error in MPC_Matrices_l.m (line 70)
Hinv=chol(W_inv);
Error in 'MPC_3Phase_Inverter/MATLAB Function1' (line 43)
Any suggestions thank you
댓글 수: 4
Sam Chak
2024년 5월 11일
편집: Sam Chak
2024년 5월 11일
Code looks okay. Check other parameters that are not shown.
%% parameters
I_2 = eye(2);
O_2 = zeros(2);
Lfilter = 1; % not shown
Cfilter = 1; % not shown
w = 1; % not shown
J = eye(2); % not shown
Tr = 1; % not shown
Vdc = 1; % not shown
%% state-space matrices
Ac_xy = [O_2 -(1/Lfilter)*I_2 O_2; (1/Cfilter)*I_2 O_2 -(1/Cfilter)*I_2; O_2 O_2 w* J];
Bc_xy = [(Vdc/Lfilter)*I_2 O_2 O_2]'*Tr;
Cxy = [I_2 O_2 O_2; O_2 I_2 O_2];
Ts = 0.1;
%% Test function
[A, B] = testcon2dis(Ac_xy, Bc_xy, Cxy, Ts)
function [A, B] = testcon2dis(Ac_xy, Bc_xy, Cxy, Ts)
ct_sys = ss(Ac_xy,Bc_xy,Cxy,[]);
dt_sys = c2d(ct_sys,Ts);
A = dt_sys.a;
B = dt_sys.b;
end
채택된 답변
Kalhara
2024년 5월 12일
% Check for NaNs
any(isnan(A(:)))
% Check for infinite values
any(isinf(A(:)))
A(isnan(A)) = 0; % Replace NaNs with zeros
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!