MATLAB Answers

0

Index exceeds the number of array elements (10), How do I solve this error??

Asked by Devesh Singh on 15 Jun 2019
Latest activity Answered by Star Strider
on 15 Jun 2019
Error in Main_Program (line 101)
Tg(xx)=(((a*Tw(xx)^2-b*Tw(xx)+c)*Tw(xx)+(Ar*Ta(xx)*hw)+Ar*Ts(xx)*(0.048*Ta(xx)-9))/((a*Tw(xx)^2-b*Tw(xx)+c)...
global N;
global ee;
dt=1;
tf=24;
nm=12;
t(1)=0;
np=(tf-t(1))/dt;
dt1=(t(1)+1)/dt;
Tw0(1)=0;
l=0.05;
a=0.02612;
b=15.76;
c=2392;
d=0.048;
e=3.8213;
w=0.0;
s=5.67*10^-8;
Ta1=[15 16.5 18 22.5 24 26 27 27 26.5 25.5 24];
Ta2=[19 23 25.5 28.5 29.5 30 32 32 31.5 31 30];
Ta3=[25.5 29.5 32 35 37 37 37.5 38 37 36 34];
Ta4=[29.5 33 35 37 38.5 38.5 38.5 39 38.5 38.5 38];
Ta5=[30 32.5 34.5 37 38.5 39.5 41 41.5 41 40 39.5];
Ta6=[33 35.5 37 39.5 41 41 42 42.5 42 41.5 40.5];
Ta7=[29.5 32.5 34 35.5 36.5 37 38 38 33 33 32.5];
Ta8=[23 25.5 28.5 30 31 32 33 33 33.5 33 32.5];
Ta9=[29 29 30 31 34 35.5 36.5 37 38 38 37];
Ta10=[33 34 35 38 39.5 40 40 39 38 37];
Ta11=[23.5 25 28 29.5 31 32 34 35 34 32.5 31];
Ta12=[20 23.5 25 26 29 31 31.5 30 30 30.5 30];
RR=[15;46;74;105;135;166;181;212;243;273;304;349];
sw=[20 23 24 25 28 28 25 25 25 25 23 20];
Z=1;
Z1=10;
V1=4;
Z0=0.03;
V=(log2(Z/Z0)/log2(Z1/Z0))*V1;
hw=2.8+3*V;
Aw=1;
Ag=1.46;
Ar=Ag/Aw;
for L=1:nm;
N=RR(L);
GTOTAL=g_t();
if L==1
disp(['Variation of temperature productivity and solar intensity'])
disp(['of January'])
Ta=Ta1';
elseif L==2
disp(['Variation of temperature productivity and solar intensity'])
disp(['of February'])
Ta=Ta2';
elseif L==3
disp(['Variation of temperature productivity and solar intensity'])
disp(['of March'])
Ta=Ta3';
elseif L==4
disp(['Variation of temperature productivity and solar intensity'])
disp(['of April'])
Ta=Ta4';
elseif L==5
disp(['Variation of temperature productivity and solar intensity'])
disp(['of May'])
Ta=Ta5';
elseif L==6
disp(['Variation of temperature productivity and solar intensity'])
disp(['of June'])
Ta=Ta6';
elseif L==7
disp(['Variation of temperature productivity and solar intensity'])
disp(['of July'])
Ta=Ta7';
elseif L==8
disp(['Variation of temperature productivity and solar intensity'])
disp(['of August'])
Ta=Ta8';
elseif L==9
disp(['Variation of temperature productivity and solar intensity'])
disp(['of September'])
Ta=Ta9';
elseif L==10
disp(['Variation of temperature productivity and solar intensity'])
disp(['of October'])
Ta=Ta10';
elseif L==11
disp(['Variation of temperature productivity and solar intensity'])
disp(['of November'])
Ta=Ta11';
elseif L==12
disp(['Variation of temperature productivity and solar intensity'])
disp(['of December'])
Ta=Ta12';
end
ee=sw(L);
Tw(1)=ee;
Ts=0.0552*Ta.^(1.5);
for xx=1:11
kk(xx)=xx+7;
q(xx)=xx;
%Ts=[10 10 9.9 9.5 8.6 8.8 9.5 10.4 11.6 12.4 13.5 15.6 15.7 15.5 14.2
%14 13.1 12.2 11.5 11.2 11 10.3 10 10];
Tg(xx)=(((a*Tw(xx)^2-b*Tw(xx)+c)*Tw(xx)+(Ar*Ta(xx)*hw)+Ar*Ts(xx)*(0.048*Ta(xx)-9))/((a*Tw(xx)^2-b*Tw(xx)+c)...
+(Ar*hw)+Ar*(0.048*Ta(xx)-9))-e);
Ti(xx)=Tw(xx)/2.0+Tg(xx)/2.0;
K(xx)=0.0244+0.7673*10^-4*Ti(xx);
Cw(xx)=999.2+0.1343*Ti(xx)+0.01*10^-4*Ti(xx)^2-6.758*10^-8*Ti(xx)^3;
Ub(xx)=K(xx)/1;
Eg=0.98;
x=647.27-(Tw(xx)+273.15);
a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
z11(xx)=Tw(xx);
t(xx+1)=t(xx)+dt
dx1b(xx)=Aw/Cw(xx)*(Eff(xx)*GTOTAL(xx)-Ut(xx)*(Tw(xx)-Ts(xx))-Ub(xx)*(Tw(xx)-Ta(xx)));
Tw(xx+1)=Tw(xx)+dx1b(xx)*dt1;
Tw1(xx)=(Tw(xx)*Tw0(1)+y(xx))*dt1;
dx1e(xx)=Aw/Cw(xx)*(Eff(xx)*GTOTAL(xx)-Ut(xx)*(Tw(xx+1)-Ts(xx))-Ub(xx)*(Tw(xx+1)+Ta(xx)));
dTw(xx)=(dx1b(xx)+dx1e(xx))/2;
Tw(xx+1)=Tw(xx)+dTw(xx)*dt;
Tw(xx+1)=Tw1(xx);
end
format short;
Tg1=Tg'
Tw2=Tw1';
dd=kk';
Mw1=Mw'*10^-5;
disp([' Time(hr) WatTemp GlasTemp ambienttemp SkyTemp Productivity x10^2 ']);
disp([dd Tw2 Tg1 Ta Ts Mw1]);
if L==1
figure(11),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(12),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(13),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(14),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(15),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
elseif L==2
figure(21),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(22),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(23),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(24),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(25),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
elseif L==3
figure(31),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(32),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(33),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(34),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(35),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
elseif L==4
figure(41),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(42),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(43),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(44),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(45),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
elseif L==5
figure(51),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(52),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(53),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(54),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(55),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
elseif L==6
figure(61),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(62),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(63),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(64),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(65),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
elseif L==7
figure(71),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(72),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(73),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(74),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(75),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
elseif L==8
figure(81),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(82),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(83),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(84),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(85),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
elseif L==9
figure(91),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(92),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(93),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(94),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(95),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
elseif L==10
figure(101),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(102),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(103),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(104),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(105),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
elseif L==11
figure(111),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(112),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(113),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(114),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(115),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
elseif L==12
figure(121),plot(dd,Tw2,'-kd',dd,Tg1,'-bs',dd,Ta,'-ro')
figure(122),plot(Mw1,Ta,'-kd',Mw1,Tw2,'-bs')
figure(123),plot(dd,GTOTAL,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(124),plot(dd,Eue,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
figure(125),plot(dd,Mw1,'-kd','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',5)
end;
end;

  0 Comments

Sign in to comment.

1 Answer

Answer by Star Strider
on 15 Jun 2019
 Accepted Answer

Five lines above it, you initialise the for loop as:
for xx=1:11
Perhaps:
for xx=1:10
will eliminate the error

  0 Comments

Sign in to comment.