Subscripted assignment dimension mismatch (size [1 x 1] ~= size [30 x 30]).

1 visualizzazione (ultimi 30 giorni)
Hi, I am new on MATLAB/SIMULINK environemt. I am trying to add a matlab function box inside a simulink model. I am importing some of the input signals from the workspace but i got the errors: Subscripted assignment dimension mismatch (size [1 x 1] ~= size [30 x 30]).
Also, how should the input dimensions be related to the script?
Below the script of the matlab fcn block
Thanks a lot
function T_sb1 =fcn(Tg,T_f,m1,U_p1)
cp=4.186;
L=30;
n=10;
dx=L/(n+1);
dt=900;
D=150;
dV=((D/(2*1000))^2)*pi*dx;
dA=((D/1000)*dx*pi);
A=((D/(2*1000))^2*L*pi);
% m1=0.5;
ro=1000;
B=(1+((m1/(dV*ro))*dt)+(U_p1*dA*dt/(2*dV*ro*cp)));
C=(m1*dt/(dV*ro));
D=(U_p1*dA*dt/(2*dV*ro*cp));
T=zeros(n,n);
for j=1:n,
for i=1:n,
T(1,1)=Tg;
T(i+1,1)=Tg;
T(1,j+1)=T_f;
T(i+1,j+1) = (T(i+1,j)+C*(T(i,j+1))-D*(T(i,j+1))+(D*2*Tg))/B;
end
end
T_sb1=T(n,:)';
  12 Commenti
MICHELE
MICHELE il 8 Mag 2014
Modificato: MICHELE il 8 Mag 2014
ok the 35040 are the recorded temp for each 15min of 1 year. T(1,1) represents the starting point, where the temp are equal to the ambient temp. I could overcome this one, simply assigning a constant average value. but for the rest of them, say T(1,j+1)=T_f or T(i+1,j+1) = (T(i+1,j)+C*(T(i,j+1))-D*(T(i,j+1))+(D*2*Tg))/B I want that at each j the code should consider each single T_f value (of the 35040 ones) as well as for m1 (included in B and C calculation). Clearly, I could consider instead of 1year, 1week or 1day but I think the prob would be the same.
MICHELE
MICHELE il 8 Mag 2014
I forgot to mention that ambient temp is Tg and that the purpose of the model will be to simulate the temp profile of my system considering the ambient temp and T_f (which represent the temp coming in from the heat generation point).

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by