Matrix size mismatch in embedded function Simulink

조회 수: 11 (최근 30일)
Daniel
Daniel 2013년 11월 4일
댓글: Daniel 2013년 11월 4일
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
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 4일
Post the entire function
Daniel
Daniel 2013년 11월 4일
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

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by