Matrix size mismatch in embedded function Simulink

1 visualizzazione (ultimi 30 giorni)
Daniel
Daniel il 4 Nov 2013
Commentato: Daniel il 4 Nov 2013
Hi, I've got the following problem: I want to create a matrix in Matlab embedded function in Simulink:
I declare first X=[] ;
and then in, a loop:
...
for i=1:n
...
X=[X; Y(i,:)];
...
end
...
where Y(i,:) is an another matrix.
Error: Size mismatch (size [0 x 0] ~= size [1 x 2])
This code works outside Simulink perfectly. Can anybody help me with that? Cheers
  2 Commenti
Daniel
Daniel il 4 Nov 2013
if true
function [Y_Reg1,Y_Reg2]=H2O_IAPWS_SpezEnthalpie(X)
T_absNull = 273.15; %K
%Region 1
T_min_Reg1 = 0; %°C
T_max_Reg1 = 623.15-T_absNull; %°C
p_max_Reg1 = H2O_Sattdampfkurve_pvonT(T_max_Reg1); %bar
%p_min = H2O_Sattdampfkurve_pvonT(T)
%Region 2
T_min_Reg2 = 0;
T_max_Reg2 = 1073.15-T_absNull; %°C
p_min_Reg2 = 0;
%p_max = H2O_Sattdampfkurve_pvonT(T)
[l_x,l_y]=size(X);
laenge_X = l_x;
T=X(:,1); %C
P=X(:,2);%in bar
if l_y > l_x && l_y>2
laenge_X=l_y;
T = X(1,:)';
P=X(2,:)';%in bar
X=[T,P];
end
X_Reg1=[];
X_Reg2=[];
P_Sattdampf=H2O_Sattdampfkurve_pvonT(T);
if true
for i=1:laenge_X
if round(P_Sattdampf(i,2)*100)/100<=round(P(i,1)*1.001*100)/100
if T(i,1)<=T_max_Reg1
X_Reg1=[X_Reg1;X(i,:)];
else
X_Reg2=[X_Reg2;X(i,:)];
end
end
if (round(P_Sattdampf(i,2)*100)/100>=round(P(i,1)*100)/100)
X_Reg2=[X_Reg2;X(i,:)];
end
end
if length(X_Reg1)>0
Y_Reg1 = H2O_IAPWS_SpezEnthalpie_Reg1(X_Reg1);
else
Y_Reg1=[];
end
if length(X_Reg2)>0
Y_Reg2 = H2O_IAPWS_SpezEnthalpie_Reg2(X_Reg2);
else
Y_Reg2=[];
end
end

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Simulink in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by