Prev: Cdata Normal
Next: SOS! How to deploy Matlab project?
From: moussams SALEY on 4 Aug 2010 10:04 Hi I am a new user of Matlab and have a problem in creating for loops. The message I have received is: ??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer. Error in ==> calculTPV2 My program file is: function dTdt= HYBRIDTPV2(t,T) % INPUT DATA Lg=0.003; Cg=810; Rog=2515; extg=26; Airgap=0.025; Emg=0.88; Transg=0.83; Alphag=1- exp(-extg*Lg/cos(asin(sin(60)/1.526))); Lc=0.002; Cc=903; Roc=2702; kc=237; Alphac=0.9; Emc=0.8; D=0.02; Di=0.018; % kair=0.025; Lin=0.02; Roin=105; Cin=795; kin=0.036; Cf = 4185.5; Rof = 1000; Nch = 3; deltay=0.1; deltaw=0.005; Itank =35/1000; mf = 0.02; Vf= 0.004; Atank=2.5; % sigma=5.6704*1e-8; epsg=0.88; epsc=0.8; Vwind=1; hwind=5.7+3.8*Vwind; Rin=(Lin/kin)+(1/hwind); Ta=293; % Indoor air temperature (K) Tf0=293; %G=5117; for i=1:13; S=[800;4851;5117;5648;5638;5509;5509;5548;5034;4825;4997;4933;4864;4394]; G=S(i); end E=(G*(66.42-0.244*(T(2)-273.15))/(970*0.485)); htank =1; hcg = 500; hcf =650; hrga = epsg*sigma*(((T(1).^2)+(Ta.^2))*(T(1)+Ta)); hrcg=sigma*((T(1).^2)+(T(2).^2))*(T(1)+T(2))/((1/epsg)+(1/epsc)-1); h1= hcg+hrcg; h2=hwind+hrga; % a = (G*Alphag+h2*Ta)/(Lg*Rog*Cg); b = h1/(Lg*Rog*Cg); c = -((h1+h2)/(Lg*Rog*Cg)); % e = (G*Alphac-E)/(Lc*Roc*Cc)+Ta/(Rin*Lc*Roc*Cc); f = h1/(Lc*Roc*Cc); h= pi*D*hcf/(Lc*Roc*Cc); g = -((h1+pi*D*hcf+1/Rin)/(Lc*Roc*Cc)); % k = (4*hcf/(D*Rof*Cf)); l = -((4*hcf/(D*Rof*Cf))+Vf/deltay); m = Vf/deltay; % n = (Nch*pi*((D/2).^2)*Vf/Itank); p = -((Nch*pi*((D/2).^2)*Vf/Itank)+(Atank*htank/(Itank*Rof*Cf))); q = Atank*htank*Ta/(Itank*Rof*Cf); % dTtankdt(j)=n*Tfout(j)+p*Ttank(j)+q % dTdt=zeros(4,1); dTdt(1)=c*T(1)+ b*T(2)+a; dTdt(2)=f*T(1)+ g*T(2)+h*T(3)+e; dTdt(3)=k*T(2)+l*T(3)+ m*Tf0; dTdt(4)=n*T(3)+ p*T(4)+q; % return Then I have created another file to call the function The file is: calculTPV2 % clc tspan=0:0.1:100; T0=[293 293 293 293]; options =odeset('OutputFcn',@odeplot); [t,T]= ode45(@HYBRIDTPV2,tspan,T0,options); plot(t,T(:,1),'b',t,T(:,2),'r',t,T(:,3),'k',t,T(:,4),'g'); I have tried to run the program with a single value of G and it works perfectly but G is the solar radiation and I have the data for one year called by S vector in my program. I would like to make the loop in order to run the program for each value of G meaning for 12months. I have tried to set the recursionLimit but it does not work: N=1000; set(0,'RecursionLimit',N); Thanks in advance for your suggestions.
From: Jan Simon on 4 Aug 2010 11:40 Dear Moussams, > ??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) > to change the limit. Be aware that exceeding your available stack space can > crash MATLAB and/or your computer. The error message means, that you call a function recursively and most likely stuck in an infinite loop. Please post also, in which line the error appears and look, why this line obviously calls the function it is contained in. BTW: > for i=1:13; > S=[800;4851;5117;5648;5638;5509;5509;5548;5034;4825;4997;4933;4864;4394]; > G=S(i); > end Much faster: S = [800;4851;5117;5648; 5638;5509;5509;5548;5034;4825; 4997;4933;4864;4394]; G = S(1:13); % Perhaps a TRANSPOSE in addition Good luck, Jan
From: Walter Roberson on 4 Aug 2010 11:49 Jan Simon wrote: > BTW: >> for i=1:13; >> >> S=[800;4851;5117;5648;5638;5509;5509;5548;5034;4825;4997;4933;4864;4394]; >> G=S(i); >> end > > Much faster: > S = [800;4851;5117;5648; > 5638;5509;5509;5548;5034;4825; > 4997;4933;4864;4394]; > G = S(1:13); % Perhaps a TRANSPOSE in addition The original code is equivalent to just doing G = S(13); which seems unlikely to be the desired result, and hints that that section of the original code probably has a bug in it (not just an inefficiency.)
|
Pages: 1 Prev: Cdata Normal Next: SOS! How to deploy Matlab project? |