Error: The "A" matrix must be a numeric array with no Inf's or NaN's.

42 vues (au cours des 30 derniers jours)
Joseph
Joseph le 10 Mai 2024
Commenté : Joseph le 13 Mai 2024
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 commentaires
Sam Chak
Sam Chak le 11 Mai 2024
Modifié(e) : Sam Chak le 11 Mai 2024
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)
A = 6x6
0.9950 0 -0.0998 0 0.0052 0 0 0.9950 0 -0.0998 0 0.0052 0.0998 0 0.9950 0 -0.1050 0 0 0.0998 0 0.9950 0 -0.1050 0 0 0 0 1.1052 0 0 0 0 0 0 1.1052
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
B = 6x2
0.0998 0 0 0.0998 0.0050 0 0 0.0050 0 0 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
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
Joseph
Joseph le 13 Mai 2024
Thank your the comment, I realise the error message genrated by the matlab didnt point exactly to the error. I realise the issue is with the AC_xy matrix which from the other sugegstion I was told to use the isany nan command to resolve it.

Connectez-vous pour commenter.

Réponse acceptée

Kalhara
Kalhara le 12 Mai 2024
% Check for NaNs
any(isnan(A(:)))
% Check for infinite values
any(isinf(A(:)))
A(isnan(A)) = 0; % Replace NaNs with zeros

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by