i want to calculate delay between appliances which are scheduled in particular hours to be run i show on and zero show off,and i am taking the plot of it,i am calculating average and maximum delay and plot it the issue is maximum delay bar is ok but

2 Ansichten (letzte 30 Tage)
i want to calculate delay between appliances which are scheduled in particular hours to be run i show on and zero show off,and i am taking the plot of it,i am calculating average and maximum delay and plot it the issue is maximum delay bar is ok but average delay bar not show because its all variables value is zero my code segment is below. _____________________________________________________________________________________________________________ Clothesdryer=[1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1]; %dl,dil 12-1pm,7am-4pm,9-11pm total running=14 Dish_washer=[0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 1 0 0 0 1 1]; %dl,dil,dnil,EL 8am-4pm,6pm,10-11pm total running=12 Washing_Machine=[0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0]; %Dnil,EL 7am-4pm total running=10 oven=[0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1]; %dnil,ndnil 7am-4pm,9-11pm total running=13 iron=[0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 0]; %dil 7am-4pm total running=12 Refrigerator=[1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0]; %(ndnil) total running=19 (20 cu.ft.(AC))(1411 watt-hours/day) Lightening=[1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]; %ndl,RL or BL not included in DSM runing=21 (100*10 watt 10 incandescent bulb) Vaccume_cleaner=[0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0]; % 7am-4pm total running=10 PoolPump=[0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1]; %dil 7-11am 10-11pm total running=7 (1.5 horsepower pump-http://www.spectralightuv.com/pool-pumps#) EWH=[0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 0]; %Electrical water heater(dil, dnil) 7am-4pm,11pm total running=11 (<http://michaelbluejay.com/electricity/howmuch.html#>) Hairdryer=[0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0];%Electrical water heater(dil, dnil) 4-10pm, total running=17 (<http://www.wholesalesolar.com/solar-information/how-to-save-energy/power-table#>) AC=[0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 0]; %8-9am,1-2pm,8-11pm running=13 hours (<http://www.wholesalesolar.com/solar-information/how-to-save-energy/power-table#>) appliances=[Clothesdryer' Dish_washer' Washing_Machine' oven' iron' Refrigerator' Lightening' Vaccume_cleaner' PoolPump' EWH' Hairdryer' AC']; arrival_appliance=appliances'; _________________________________________________________ for i = 1:popsize psum(:,i)=popnew(i,:)*p'; sum1=psum; ts1=strfind(Clothesdryer,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1 1]); %14 strfind,findstr ts2=strfind(Dish_washer,[1]);% 1 1 1 1 1 1 1 1 1 1 1]); %12 ts3=strfind(Washing_Machine,[1]);% 1 1 1 1 1 1 1 1 1]); %10 ts4=strfind(oven,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1]); %13 ts5=strfind(iron,[1]);% 1 1 1 1 1 1 1 1 1 1 1]); %12 ts6=strfind(Refrigerator,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]); %19 bits ts7=strfind(Lightening,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]);%21 ts8=strfind(Vaccume_cleaner,[1]);% 1 1 1 1 1 1 1 1 1]);%10 ts9=strfind(PoolPump,[1]);% 1 1 1 1 1 1]);%7 ts10=strfind(EWH,[1]);% 1 1 1 1 1 1 1 1 1 1]);%11 ts11=strfind(Hairdryer,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]);%17 ts12=strfind(AC,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1]);%13 if (F(i,1)<D11)&(sum1(1,i)<Plimit) D11 = F(i,1); if (gen>1) %------------------------------% %A & B (A and B are %evaluated), A && B (B is only evaluated if A is true)% if popnew(gen-1,1)==1 tf1=gen; else tf1=0; end D1=tf1-ts1; if (D1>=3)&(nnz(Clothesdryer)<14) popnew(i,1)=1; else popnew(i,1)=0; end %------------------------------% if popnew(gen-1,2)==1 tf2=gen; else tf2=0; end D2=tf2-ts2; if (D2>=3)&(nnz(Dish_washer)<12) popnew(i,2)=1; else popnew(i,2)=0; end %------------------------------% if popnew(gen-1,3)==1 tf3=gen; else tf3=0; end D3=tf3-ts3; if (D3>=3)&(nnz(Washing_Machine)<10) popnew(i,3)=1; else popnew(i,3)=0; end %------------------------------% if popnew(gen-1,4)==1 tf4=gen; else tf4=0; end D4=tf4-ts4; if (D4>=3)&(nnz(oven)<13) popnew(i,4)=1; else popnew(i,4)=0; end %------------------------------% if popnew(gen-1,5)==1 tf5=gen; else tf5=0; end D5=tf5-ts5; if (D5>=3)&(nnz(iron)<12) popnew(i,5)=1; else popnew(i,5)=0; end %------------------------------% if popnew(gen-1,6)==1 tf6=gen; else tf6=0; end D6=tf6-ts6; if (D6>=3)&(nnz(Refrigerator)<19) popnew(i,6)=1; else popnew(i,6)=0; end %------------------------------% if popnew(gen-1,7)==1 tf7=gen; else tf7=0; end D7=tf7-ts7; if (D7>=3)&(nnz(Lightening)<21) popnew(i,7)=1; else popnew(i,7)=0; end %------------------------------% if popnew(gen-1,8)==1 tf8=gen; else tf8=0; end D8=tf8-ts8; if (D8>=3)&(nnz(Vaccume_cleaner)<10) popnew(i,8)=1; else popnew(i,8)=0; end %------------------------------% if popnew(gen-1,9)==1 tf9=gen; else tf9=0; end D9=tf9-ts9; if (D9>=3)&(nnz(PoolPump)<7) popnew(i,9)=1; else popnew(i,9)=0; end %------------------------------% if popnew(gen-1,10)==1 tf10=gen; else tf10=0; end D10=tf10-ts10; if (D10>=3)&(nnz(EWH)<11) popnew(i,10)=1; else popnew(i,10)=0; end %------------------------------% if popnew(gen-1,11)==1 tf11=gen; else tf11=0; end D11=tf11-ts11; if (D11>=3)&(nnz(Hairdryer)<17) popnew(i,11)=1; else popnew(i,11)=0; end %------------------------------% if popnew(gen-1,12)==1 tf12=gen; else tf12=0; end D12=tf12-ts12; if (D12>=3)&(nnz(AC)<13) popnew(i,12)=1; else popnew(i,12)=0; end %------------------------------% else %(gen<13)&&(gen>22) popnew(i,1)=0; popnew(i,2)=0; popnew(i,3)=0; popnew(i,4)=0; popnew(i,5)=0; popnew(i,6)=0; popnew(i,7)=0; popnew(i,8)=0; popnew(i,9)=0; popnew(i,10)=0; popnew(i,11)=0; popnew(i,12)=0; end ________________________________________________ %ts1=findstr(Clothesdryer,[1 1 1]); %tss starting time slot tf1=strfind(Clothesdryer,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1 1]); %finish time slot D1=sum(abs(ts1-tf1)); %calculate dealy D_1=D1/14; Dmax1=24-14; %calculate maximum delay user_comfort1=D1/Dmax1*100; %user_comfort1 (1.dl,dil,dnil) user_comfort1dl %Maximum delay=24-LOT %Maximum delay=24-LOT %Average Delay=Start time of appliance i before scheduling-Start time of appliance i after scheduling/LOT %--------------------------------------------------% %user comfort=average delay/maximum delay %ts2=findstr(Dish_washer,[1 1 1 1 1 1 1 1]); tf2=strfind(Dish_washer,[1]);% 1 1 1 1 1 1 1 1 1 1 1]); D2=sum(abs(ts2-tf2)); D_2=D2/12; Dmax2=24-12; user_comfort2=D2/Dmax2*100; %user_comfort2 (2.dil,dnil,el,dl) %--------------------------------------------------% %ts3=findstr(Washing_Machine,[1 1]); tf3=strfind(Washing_Machine,[1]);% 1 1 1 1 1 1 1 1 1]); D3=sum(abs(ts3-tf3)); D_3=D3/10; Dmax3=24-10; user_comfort3=D3/Dmax3*100; %user_comfort3 (3.dl,dnil,el) user_comfort3dl %--------------------------------------------------% %ts4=findstr(oven,[1 1 1 1 1 1 1]); tf4=strfind(oven,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1]); D4=sum(abs(ts4-tf4)); D_4=D4/13; Dmax4=24-13; user_comfort4=D4/Dmax4*100; %user_comfort4 (4.ndnil,dnil) %user_comfort4 (4.ndnil,dnil) %--------------------------------------------------% %ts5=findstr(iron,[1 1 1 1]); tf5=strfind(iron,[1]);% 1 1 1 1 1 1 1 1 1 1 1]); D5=sum(abs(ts5-tf5)); D_5=D5/12; Dmax5=24-12; user_comfort5=D5/Dmax5*100; %user_comfort5 (5.ndl) %user_comfort5 (5.ndl) %--------------------------------------------------% %ts6=findstr(Refrigerator,[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]); tf6=strfind(Refrigerator,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]); D6=sum(abs(ts6-tf6)); D_6=D6/19; Dmax6=24-19; user_comfort6=D6/Dmax6*100; %user_comfort6 (6.ndnil,dl) user_comfort6dl %user_comfort6 (6.ndnil,dl) %--------------------------------------------------% %ts7=findstr(Lightening,[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]); tf7=strfind(Lightening,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]); % optional lightening 21 hours and compulsory lightening 24 hours D7=sum(abs(ts7-tf7)); D_7=D7/21; Dmax7=24-21; user_comfort7=D7/Dmax7*100; %user_comfort8 (7.rl,ndl,ndnil,ndil) user_comfort7rl %--------------------------------------------------% %ts8=findstr(Vaccume_cleaner,[1 1 1 1]); tf8=strfind(Vaccume_cleaner,[1]);% 1 1 1 1 1 1 1 1 1]); D8=sum(abs(ts8-tf8)); D_8=D8/10; Dmax8=24-10; user_comfort8=D8/Dmax8*100; %user_comfort8 (8.dl,dil,dnil) user_comfort8dl %--------------------------------------------------% %ts9=findstr(PoolPump,[1 1]); tf9=strfind(PoolPump,[1]);% 1 1 1 1 1 1]); D9=sum(abs(ts9-tf9)); D_9=D9/7; Dmax9=24-7; user_comfort9=D9/Dmax9*100; %user_comfort9 (9.dl) user_comfort9dl %--------------------------------------------------% %ts10=findstr(EWH,[1 1 1 1]); tf10=strfind(EWH,[1]);% 1 1 1 1 1 1 1 1 1 1]); D10=sum(abs(ts10-tf10)); D_10=D10/11; Dmax10=24-11; user_comfort10=D10/Dmax10*100; %user_comfort10 (10.dil,dnil,ndl) %user_comfort10 (10.dil,dnil,ndl) %--------------------------------------------------% %ts11=findstr(Hairdryer,[1 1 1 1 1 1 1 1]); tf11=strfind(Hairdryer,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]); D11=sum(abs(ts11-tf11)); D_11=D11/17; Dmax11=24-17; user_comfort11=D11/Dmax11*100; %user_comfort11 (11.ndl) %user_comfort11 (11.ndl) %-------------------------------------------------------------------% %ts11=findstr(Hairdryer,[1 1 1 1 1 1 1 1]); tf12=strfind(AC,[1]);% 1 1 1 1 1 1 1 1 1 1 1 1]); D12=sum(abs(ts12-tf12)); D_12=D12/13; Dmax12=24-13; user_comfort12=D12/Dmax12*100; %user_comfort12 (12.ndl) %user_comfort12 (12.ndnil,dil) %-------------------------------------------------------------------% %-------------------------------------------------------------------% %-------------------------------------------------------------------% Dmaxdl=(Dmax1+Dmax3+Dmax6+Dmax7+Dmax11)/5; Ddl=(D_1+D_3+D_6+D_7+D_11)/5; user_comfortdl=Ddl/Dmaxdl*100; %user comfort dl %--------------------user comfort dl------------------------------% Dmaxndl=(Dmax5+Dmax10+Dmax11)/3; Dndl=(D_5+D_10+D_11)/3; user_comfortndl=Dndl/Dmaxndl*100; %user comfort ndl %-------------------user comfort ndl-------------------------------% Dmaxndnil=(Dmax4+Dmax6+Dmax12)/3; Dndnil=(D_4+D_6+D_12)/3; user_comfortndnil=Dndnil/Dmaxndnil*100; %user comfort ndnil %-------------------user comfort dnil-------------------------------% Dmaxdil=(Dmax1+Dmax2+Dmax7+Dmax11+Dmax12)/5; Ddil=(D_1+D_2+D_7+D_11+D_12)/5; user_comfortdil=Ddil/Dmaxdil*100; %user comfort dil %-----------------user comfort dil---------------------------------% Dmaxdnil=(Dmax1+Dmax2+Dmax3+Dmax4+Dmax7+Dmax11)/6; Ddnil=(D_1+D_2+D_3+D_4+D_7+D_11)/6; user_comfortdnil=Ddnil/Dmaxdnil*100; %user comfort dnil %-------------------user comfort dnil-------------------------------% Dmaxndil=(Dmax7)/1; Dndil=(D_7)/1; user_comfortndil=Dndil/Dmaxndil*100; %user comfort ndil %---------------------user comfort ndil-----------------------------% Dmaxrl=(Dmax7)/1; Drl=(D_7)/1; user_comfortrl=Drl/Dmaxrl*100; %user comfort rl %--------------------user comfort rl------------------------------% Dmaxel=(Dmax2+Dmax3)/2; Del=(D_2+D_3)/2; user_comfortel=Del/Dmaxel*100; %user comfort el %--------------------user comfort el------------------------------% Dmaxlceg=(Dmax1+Dmax2+Dmax3+Dmax4+Dmax5+Dmax6+Dmax7+Dmax8+Dmax9+Dmax10+Dmax11+Dmax12)/12; Dlceg=(D_1+D_2+D_3+D_4+D_5+D_6+D_7+D_8+D_9+D_10+D_11+D_12)/12; user_comfortlceg=Dlceg/Dmaxlceg*100; %user comfort lceg %-----------------user comfort lceg---------------------------------% Dmaxlcd=(Dmax2+Dmax3+Dmax7)/3; Dlcd=(D_2+D_3+D_7)/3; user_comfortlcd=Dlcd/Dmaxlcd*100; ________________________________________________________________________ figure % Fig#2 y=[Ddl Dmaxdl;Dndl Dmaxndl;Dndnil Dmaxndnil;Ddil Dmaxdil;Ddnil Dmaxdnil;Dndil Dmaxndil;Drl Dmaxrl;Del Dmaxel;Dlceg Dmaxlceg;Dlcd Dmaxlcd]; % bar(1,0,0.3,'red') % hold on % bar(2,D_5,0.3,'blue') % hold on % bar(3,D,0.3,'magenta') bar(y) legend('Avg. waiting time','Max. waiting time') set(gca, 'XTick',1:1:10, 'XTickLabel',{'dl','ndl','ndnil','dil','dnil','ndil','rl','el','lceg','lcd'}) ylabel('Waiting time (hours)') grid on _____________________________________ in the above plot the variable Ddl,Dndl,Dndnil,Ddil,Ddnil,Dndil,Drl,Del,Dlceg,Dlcd are all show zero value ,i know the problem is with strfind function,may be my logic is wrong or i did not gave correct values,the plot show only bar for maximum delay value kindly need help and suggestions?

Antworten (0)

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by