رفتن به مطلب

helen66

کاربر انجمن
  • تعداد ارسال ها

    188
  • تاریخ عضویت

  • آخرین بازدید

تمامی مطالب نوشته شده توسط helen66

  1. helen66

    سوال در مورد رسم نمودار

    ممنون از راهنماییتون مهندس.درستش کردم.
  2. helen66

    سوال در مورد رسم نمودار

    این زمان هست که باید واسه هر ساعت ی ماتریس 30*1 داشته باشیم. الان چیو باید حذف کنم؟
  3. helen66

    سوال در مورد رسم نمودار

    سلام میخوام توخروجی 24 تا ماتریس 30*1 برای soc ,همینطور برای soc0 هم 24 تا ماتریس داشته باشم. نمیدونم soc و soc0 رو کجا بذارم که که این نتیجه رو بده.
  4. helen66

    سوال در مورد رسم نمودار

    سلام دوستان،وقتتون بخیر من ی کد دارم میخوام تو 24 ساعت،در هر ساعتش ی خروجی بهم بده میشه کمکم کنید لطفا؟ در کد زیر در هر ساعت ی soc و ی so0 داشته باشم...و 24 تا نمودار واسه soc , 24 تا واسه soc0.... ممنون SOC0=0.25+0.75*rand(1,30); %SOC0=[0.3334 0.8352 0.5423 0.4313 0.5529 0.3223 0.3490 0.9565... % 0.9671 0.6814 0.2948 0.4261 0.5149 0.8659 0.2616 0.2823... % 0.3767 0.7368 0.7988 0.7358 0.5882 0.6603 0.4722 0.8085... % 0.3917 0.7651 0.3876 0.5264 0.7192 0.8352]; Nv=30; for h=1:24 % Ich = randerr(Nv,3,1); Iv=[ 1 0 0 0 0 1 1 0 0 0 1 0 0 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0 1 0 1 0 1 0 0 1 0 0 0 0 1 0 1 0 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0]; for i=1:Nv Idch=Iv(i,1); Ich=Iv(i,2); Iidle=Iv(i,3); if (SOC0(i) Idch=0; k=rand; if k>0.5 Ich=1; end if k Iidle=1; end end if (SOC0(i)>=1 && Ich==1) Ich=0; k=rand; if k>0.5 Idch=1; end if k Iidle=1; end end Ivv(i,:)=[idch Ich Iidle]; SOC(i)=SOC0(i)+(Ich-Idch)*.2; SOC(SOC>1)=1; %SOC0 % SOC end % SOC0=SOC end Ivv SOC0 SOC %rand(1,nVar) %figure %bar(SOC) %xlabel('PHEV'); %ylabel('SOC'); %hold on %figure %bar(SOC0) %xlabel('PHEV'); %ylabel('SOC0');
  5. helen66

    تنظیم نمودار

    سلام ممنون مهندس .همه تغییراتو اعمال کردم ولی نشد....
  6. helen66

    دستور if

    فرقی نداره بازم اعداد بزرگتر از 1 تولید میشه!
  7. helen66

    دستور if

    فرقی نداره بازم اعداد بزرگتر از 1 تولید میشه!
  8. helen66

    تنظیم نمودار

    با سلام میخوام اعداد زیر نمودار بصورت عمودی نشون داده بشه...ممنون میشم راهنماییم کنید..مثلا واسه کد زیر: clc clear all close all mu = 3.2; sigma = 2.9; t=lognrnd(3.2,0.9,1,1000); h = zeros(1,21); range = linspace(-1.3,7.7,22); for i = 1:1000 for j = 1:21 if t(i)>= range(j) && t(i) h(j) = h(j) + 1; elseif t(i)== range(end) h(end) = (h(end) + 1); end end end bar(h) xlabel('daily travel miles'); ylabel('% of vehicles'); set(gca,'XTickLabel',{'0-5','5-10','10-15','15-20','20-25','25-30'... '30-35','35-40','40-45','45-50','50-55','55-60','60-65'... '65-70','70-75','75-80','80-85','85-90','90-95','95-100',}) set(gca,'XTick',1:21)
  9. helen66

    دستور if

    با سلام میخوام به کد زیر ی دستور if اضافه کنم ولی ج درست نمیده میشه راهنماییم کنید؟ (میخوام نشون بدم اگر در جواب socinitial>1 شد انگاه socinitial=1 بشه) if (landa.*d)>zeros(30,1),(landa.*d) socinitial=abs(1-(landa.*d)./dr1) elseif (landa*d)>=0.8*dr1; socinitial=0.2 end if socinitial>=1 socinitial==1 end
  10. helen66

    انتقال نمودار

    مرسسسسیی درست شد.
  11. helen66

    انتقال نمودار

    مرسی از پاسختون...دقیقا از چه مسیری باید تو ویزیو عکسو باز کنم؟؟؟
  12. helen66

    انتقال نمودار

    با سلام دوستاان کسی با نرم افزار ویزیو اشنایی داره؟ میخواستم ببینم میشه نمودارها رو از متلب به ویزیو کپی کرد؟ با سپاس
  13. helen66

    تبدیل ماتریس سه بعدی به دوبعدی

    بله میخوام از این 72 ارایه 32 تا شو تصادفی انتخاب کنم وبشه ی ماترسی 1*32
  14. helen66

    تبدیل ماتریس سه بعدی به دوبعدی

    ممنون از پاسختون مشکلم اینه که باید ابعاد ماتریسو کم کنم چنین چیزی امکان داره؟ مثلا ی ماتریس 72*1 رو به 1*32 تبدیل کنم؟
  15. helen66

    تبدیل ماتریس سه بعدی به دوبعدی

    با سلام و وقت بخیر چطور میتونم ی ماتریس سه بعدی رو به دوبعدی تبدیل کنم؟ مثلا: size(ZB) 24 3 1 بشه: 1 32
  16. سلام چطور میتونیم مثلا ی ماتریس 3*3 داشته باشیم یعد هر ستونشو برای ادامه برنامه بصورت جدا ی ماتریس 1*3 تعریف کنیم؟مثلا: [1 2 3;4 5 2;6 8 7]=k [3;2;7]=l
  17. مررررررسی مهندس عالی بود....میشه راجب خط دوم ی توضیح مختصر بدید؟ ممنون
  18. مهندس همین کدی که نوشتینو ابعادشو چطور تغییر بدم و 3 بعدیش کنم؟
  19. ممنون مهندس از پاسختون.بله حتما باید 3 بعدی باشه...استادم گفت میشه با randi و xor نوشت ولی نمیدونم چطوری باید بنویسمش...
  20. helen66

    داشتن فقط یک مقدار غیر صفر در یک ماتریس

    با سلام میخوام کد زیرو طوری تغییر بدم که تو هر ردیف (سطر) فقط ی دونه 1 داشته باشم....ولی نمیدونم چیکارش کنم...ممنون میشم کمکم کنید. با تشکر Id=randi([0,1],10,3,24) مثلا سطر اخر که: 1 0 1 هست ،بشه 1 0 0
  21. helen66

    مشکل در متلب

    با سلام دوستان کسی نتونست مشکل بالا رو حل کنه؟؟؟
  22. helen66

    مشکل در متلب

    کد cos222 function cost1 = cost222(Prate ) %UNTITLED3 Summary of this function goes here % Detailed explanation goes here % daily travel distance beta1=0.1; beta2=0.2; alfa=10; t=1:24; a=readfis('gu1'); %Read a fuzzy inference system from a gu1 x=normrnd(9.97,2.2,24,1); %depend on arrival time y=normrnd(17.01,3.2,24,1); %depond on departure time d=evalfis([x y],a); %daily travel distance aer=[30,40,60]; %DIFFERENT AERS dr1=aer(randi([1,3],1)); landa=d./100; %percentage of mileage driven in all electrical... % mode if (landa.*d)>zeros(24,1),(landa.*d)<(0.8.*dr1); socinitial=(1-(landa.*d)./dr1)*100; elseif (landa*d)>=0.8*dr1; socinitial=0.2; end %BATTERY CAPACITY FOR DIFFERENT TYPES OF PHEV (kWh) h1=[7.8,9,11.4,13.8]; p1=h1(randi([1,4],1,1)); h2=[10.4,12,15.2,18.4]; p2=h2(randi([1,4],1,1)); h3=[15.6,18,22.8,27.6]; p3=h3(randi([1,4],1,1)); p=[p1 p2 p3]; eta=0.85+(0.9-0.85)*rand(1,24); % the charging efficiency factor c=p(randi(1,1,24)); %BATTERY CAPACITY ereq=((1-socinitial).*c')./eta'; %The energy required to fulfill the battery %Smart Pricing Policy psys=ereq'./t; %load demand of the system at time slot pavg=ereq./24; %the average load demand of the system % disp(rt); % kd1=eye(1,100); k=[-1,0,1]; kd=k(randi([1,3],1,24 )); %charging strategy %the rated charging power of the dth PHEV for pp=1:24 rt(pp)=beta1+(beta2*(alfa.^((psys(pp)-pavg(pp))./pavg(pp)))); end for t=1:24 coschg(t)=abs( kd(t)*Prate(t).*rt(t)); %charging cost end % disp(coschg) %Battery Degradation Cost cl=240; lc=5000; % etadis=0.8; cb=300; % Edis=300; DOD=0.8; h1=[7.8,9,11.4,13.8,10.4,12,15.2,18.4,15.6,18,22.8,27.6]; Eb=h1(randi([1,12],1,24)); % kd1=eye(1,100); k=[-1,0,1]; kd=k(randi([1,3],1,24 )); Dd=zeros(1,24); Dd(kd==-1)=1; %discharging state of PHEVs for t=1:24 Edis(t)=Dd(t).*Prate(t); costbat(t)=abs((((cb*Eb(t))+cl)/((lc*DOD)*Eb(t)))*Edis(t));%discharge energy by PHEVs end %Battery Degradation Cost % disp(costbat); reg=.4928; %regulation service price at time slot % kd1=eye(1,100); k=[-1,0,1]; kd=k(randi([1,3],1,24 )); %charging strategy %the rated charging power of the dth PHEV Id=zeros(1,24); %idle state of PHEVs Id(kd==0)=1; %the frequency regulation capacity of the system Earnreg=0; for t=1:24 pr(t)=Id(t).*Prate(t); Earnreg=Earnreg+abs(pr(t).*reg); %revenue earned by regulation service end qq=sum(coschg); qqq=sum(costbat); qqqq=Earnreg; % Earnreg1=Earnreg.*eye(1,100); cost1=sum(coschg)+sum(costbat)-Earnreg; end
  23. helen66

    مشکل در متلب

    کد espso clc clear; close all; %% Problem Definition global NFE; CostFunction=@(Prate) cost222(Prate); % Cost Function nVar=24; % Number of Decision Variables VarSize=[1 nVar]; % Size of Decision Variables Matrix % Lower Bound of Variables VarMax=6 ; % Upper Bound of Variables PL=[1.7 1.5 1.3 1.32 1.4 1.52 1.6 1.9 2.1 2.25 2.4 2.5 2.55 2.56 2.59 2.55 ... 2.8 3.2 3.5 3.7 3.73 3.4 3 2.3]; VarMin=PL ; %% PSO Parameters MaxIt=300; % Maximum Number of Iterations nPop=30; % Population Size (Swarm Size) wmax=1; % Inertia Weight wmin=0.2; % Inertia Weight Damping Ratio c1=2; % Personal Learning Coefficient c2=2; % Global Learning Coefficient % Constriction Coefficients % phi1=2.05; % phi2=2.05; % phi=phi1+phi2; % chi=2/(phi-2+sqrt(phi^2-4*phi)); % w=chi; % Inertia Weight % wdamp=1; % Inertia Weight Damping Ratio % c1=chi*phi1; % Personal Learning Coefficient % c2=chi*phi2; % Global Learning Coefficient % Velocity Limits VelMax=0.1*(VarMax-VarMin); VelMin=-VelMax; %% Initialization empty_particle.Position=[]; empty_particle.Cost=[]; empty_particle.Velocity=[]; empty_particle.Best.Position=[]; empty_particle.Best.Cost=[]; particle=repmat(empty_particle,nPop,1); GlobalBest.Cost=inf; for i=1:nPop Prate=randsrc(1,1,[.001:.01:.2])*PL+PL; % Initialize Position particle(i).Position=Prate; % Initialize Velocity particle(i).Velocity=zeros(VarSize); % Evaluation particle(i).Cost=CostFunction(particle(i).Position); % Update Personal Best particle(i).Best.Position=particle(i).Position; particle(i).Best.Cost=particle(i).Cost; % Update Global Best if particle(i).Best.Cost<GlobalBest.Cost GlobalBest=particle(i).Best; end end disp('aaaa') BestCost=zeros(MaxIt,1); nfe=zeros(MaxIt,1); w=1; %% PSO Main Loop for it=1:MaxIt for i=1:nPop % Update Velocity particle(i).Velocity = w*particle(i).Velocity ... +c1*rand(VarSize).*(particle(i).Best.Position-particle(i).Position) ... +c2*rand(VarSize).*(GlobalBest.Position-particle(i).Position); % Apply Velocity Limits particle(i).Velocity = max(particle(i).Velocity,VelMin); particle(i).Velocity = min(particle(i).Velocity,VelMax); % Update Position particle(i).Position = particle(i).Position + particle(i).Velocity; % Velocity Mirror Effect % IsOutside=(particle(i).Position<VarMin | particle(i).Position>VarMax); % particle(i).Velocity(IsOutside)=-particle(i).Velocity(IsOutside); % % Apply Position Limits particle(i).Position = max(particle(i).Position,VarMin); particle(i).Position = min(particle(i).Position,VarMax); %for iv=1:24 % particle(iv).Position(iv)= PL(iv)+rand*1e2; %end % Evaluation particle(i).Cost = CostFunction(particle(i).Position); % Update Personal Best if particle(i).Cost<particle(i).Best.Cost; particle(i).Best.Position=particle(i).Position; particle(i).Best.Cost=particle(i).Cost; % Update Global Best if particle(i).Best.Cost<GlobalBest.Cost GlobalBest=particle(i).Best; end end end BestCost(it)=GlobalBest.Cost; disp(['Iteration ' num2str(it) ', Best Cost = ' num2str(BestCost(it))]); w=wmax-it*((wmax-wmin)/MaxIt); end %% Results cost1 = zzz(GlobalBest.Position ); figure; plot([1:300],BestCost,'LineWidth',2); xlabel('Iteration'); ylabel('Best Cost'); [PLOSS V]=foku(GlobalBest.Position); figure; plot([1:34],V,'-*'); xlabel('BUS'); ylabel('Voltage');
  24. helen66

    مشکل در متلب

    با سلام و وقت بخیر ممنون از پاسخ مفیدتون...تعداد کدها زیاده اونها رو بصورت مجزا قرار میدم ممنون میشم کمکم کنید،کد نهایی espso هستش که سرعتش پایینه: function [PLOSS V]=foku(xx) countnum=0; BranchData = [ 1 2 1.00922 1.00470; 2 3 1.004930 1.002511; 3 4 0.003660 0.1864; 4 6 0.03811 0.1941; 4 5 0.03811 0.1941; 6 7 0.1872 0.6188; 7 8 0.7114 0.2351; 8 9 1.0300 0.7400; 9 10 1.0440 0.7400; 10 11 0.0966 0.0650; 11 12 0.0744 0.1238; 9 13 0.0680 1.1550; 13 14 0.0416 0.7129; 13 15 0.0910 0.5260; 15 16 0.0463 0.5450; 16 17 0.2890 1.7210; 17 18 0.7320 0.5740; 17 19 0.1640 0.1565; 19 20 0.5042 1.3554; 20 21 0.4095 0.4784; 21 22 0.7089 0.9373; 20 23 0.4512 0.3083; 23 24 0.8980 0.7091; 23 25 0.8960 0.7011; 25 26 0.2030 0.1034; 26 27 0.2842 0.1447; 27 28 0.0590 0.9337; 28 29 0.8042 0.7006; 25 30 0.5075 0.2585; 30 31 0.9744 0.9630; 31 32 0.3105 0.3619; 31 33 0.3410 0.5302; 33 34 0.3410 0.5302; ]; NodeData = [ 2 100.00 60.00; 3 90.00 40.00; 4 80.00 80.00; 5 60.00 30.00; 6 60.00 80.00; 7 80.00 80.00; 8 80.00 90.00; 9 60.00 20.00; 10 60.00 20.00; 11 45.00 80.00; 12 60.00 65.00; 13 60.00 65.00; 14 120.00 80.00; 15 60.00 60.00; 16 60.00 60.00; 17 60.00 60.00; 18 90.00 40.00; 19 90.00 40.00; 20 90.00 40.00; 21 90.00 40.00; 22 90.00 40.00; 23 90.00 50.00; 24 80.00 10.00; 25 80.00 10.00; 26 60.00 65.00; 27 60.00 65.00; 28 60.00 60.00; 29 80.00 70.00; 30 100.00 30.00; 31 150.00 70.00; 32 110.00 100.00; 33 60.00 40.00; 34 60.00 40.00; ]; UB = 12.66; SB = sum(xx) ; ZB = UB^2/SB; BranchData(:,[3,4]) = BranchData(:,[3,4]) / ZB; NodeData(:,[2,3]) = NodeData(:,[2,3]) / SB / 1800; NN = 34; A0 = zeros(NN); for n = 1:NN-1 A0(BranchData(n,1),BranchData(n,2)) = 1; end AssociatedMatrix=0; for n=2:NN-1 AssociatedMatrix(n,n)=1; temp=BranchData(n-1,1); AssociatedMatrix(n,1:n-1)=AssociatedMatrix(temp,1:n-1); end A0T = A0'; S = [0;-NodeData(:,2) - 1i*NodeData(:,3)]; ZL = [0;BranchData(:,3) + 1i*BranchData(:,4)]; V = ones(NN,1); V(1) = 1; IL(NN,1) = -conj(S(NN) / V(NN)); Delta = 1; TempV = V; while Delta > 1e-3 countnum=countnum+1; IN = conj(S ./ V); for n = 1:NN-1 IL(NN-n) = A0(NN-n,NN-n+1:end) * IL(NN-n+1:end) - IN(NN-n); end for n = 2:NN V(n) = A0T(n,1:n-1) * V(1:n-1) - ZL(n) * IL(n); end Delta = max(abs(V-TempV)); TempV = V; end Vangle(:,1)=abs(V); Vangle(:,2)=angle(V)/3.1415*180; for i=1:NN-1 st=BranchData(i,1); en=BranchData(i,2); Sij(i,1)=V(st)*conj((V(st)-V(en))/ZL(i+1)); Sji(i,1)=V(en)*conj((V(en)-V(st))/ZL(i+1)); end PLOSS=sum(real(Sij))*1000-(SB/1.2); end
  25. helen66

    مشکل در متلب

    با سلام و وقت بخیر چطور میتونم سرعت اجرای ی برنامه تو متلب رو بالا ببرم؟ با سپاس
×
×
  • اضافه کردن...