Hello everybody, I have a code in .m on Matlab and i would like implemented it in an embedded function on simulink. It is ok on Matlab but on simulink not. I have an error concerning the storage and more particularly the dimensions about this storage :
function [Vt_1,Pt_1] = mpp(V,G,T) k = 1.381e-23; q = 1.602e-19; n=1.486; Eg = 1.12; Ns = 34;Tref = 298; Voc_Tref = 21.6 /Ns;%Module PWX500
Isc_Tref = 3.1;%Module PWX500 Va=V/Ns;Ta=T+273;Iph_Ta = Isc_Tref* G + (0.00095*(Ta-Tref));Vt= n*k * Tref / q; I0_Tref = Isc_Tref / (exp(Voc_Tref/Vt)-1); b = Eg * q/(n*k); I0_Ta = I0_Tref * (Ta/Tref)^(3/n) * exp(-b*(1/Ta - 1/Tref)); I_cons=1.55;V_cons=20.1 / Ns;Vt_e= n*k * Tref / q;I0_Tre = Isc_Tref / (exp(Voc_Tref/Vt_e)-1);VD=Vt_e * log(I_cons/I0_Tre);Rs = (VD-V_cons)/I_consVt_Ta = n * k * Ta / q; Ia =0; Ia = Ia -(Iph_Ta - Ia - I0_Ta.*( exp((Va+Ia.*Rs)./Vt_Ta) -1))./ (-1 - I0_Ta.*(Rs./Vt_Ta).* exp((Va+Ia.*Rs)./Vt_Ta));Va=V;Pa= Va*Ia;V_2=Va+0.2;Vt = [];Pt = [];for t= 1:46800 %13h
%G_1=yi(t);
V_1=V_2; V_b=V_1/Ns; Iph_Ta = Isc_Tref* G *(1+(0.00095*(Ta-Tref))); I_1=I_1 -(Iph_Ta - I_1 - I0_Ta.*( exp((V_b+I_1.*Rs)./Vt_Ta) -1))./ (-1 - I0_Ta.*(Rs./Vt_Ta).* exp((V_b+I_1.*Rs)./Vt_Ta)); P_1=V_1*I_1; Delta_P=P_1-Pa; if Delta_P> 0 if V_1>Va V_2=V_1 + 0.2; %augmente la tension
else V_2=V_1 - 0.2; %diminue la tension
end elseif Delta_P<0 if V_1>Va V_2=V_1 - 0.2; %diminue la tension else V_2=V_1 + 0.2; %augmente la tension
end else V_2=V_1; end Va=V_1; Pa=P_1; Vt =[Vt Va]; Vt_1=max(Vt); Pt = [Pt Pa]; Pt_1=max(Pt); t=t+1; %t=0;
end end
I have Vt=[] and Pt=[] and after the loop, I store every variable of Va and Pa in Vt=[Vt Va] and Pt=[Pt Pa]. But on simulink, i have this error :
Computed maximum size is not bounded.Static memory allocation requires all sizes to be bounded.The computed size is [1 x :?].This error may be reported due to a limitation of the underlying analysis.
Thank you for your help,
Best Answer