how can i put a limitation rules for below codes?

1 回表示 (過去 30 日間)
Mamad Mamadi
Mamad Mamadi 2019 年 12 月 15 日
編集済み: Mamad Mamadi 2020 年 1 月 14 日
i have some values of Pch=Pcharging and Pdis=Pdischarging that i mentioned below and i want to write codes for limitation but the codes that i wrote is not working specially for Pch. Could you please and please help me. thanks
i mean;
Pmax= 3600wh
Pmin=0wh
Pch wont be 3750 , must not be bigger than 3600
Pdis wont be -150, must not be smaller than 0
Pch=[2600 2750 2800 2950 3010 3100 3300 3580 3750];
Pdis=[3450 3330 2900 1500 1200 850 300 22 -150];
it these codes right? if not how can i write it?
%%% for Pch:
a=1;
b=0;
result_data=[];
while a<=length(Pch);
b= Pch(a)+b;
result_data(a+1)=b;
a=a+1;
if result_data <= Pmax ;
finalresult = result_data;
elseif result_data > Pmax ;
break;
end
finalresult;
end
%%% for Pdis
if Pdis(1,i) >= Pmin;
Pdis_1=Pdis(1,i);
elseif Pdis(1,i) < Pmin
Pdis(Pdis<0)=0;
end
  2 件のコメント
Rik
Rik 2019 年 12 月 15 日
What should happen with the values that are not allowed? Should they be removed from the vector, or should they be assigned the boundary value?
Mamad Mamadi
Mamad Mamadi 2019 年 12 月 16 日
Because the capacity of the battery is 3600wh then we cannot charge the battery bigger than 3600wh so we dont need the values that bigger than Pmax=3600wh we can remove it.
And also for Pdis is the same action, it cannot be smaller than Pmin=0

サインインしてコメントする。

回答 (1 件)

Rik
Rik 2019 年 12 月 16 日
With logical indexing it is easy to remove impossible values:
Pmax= 3600;
Pmin=0;
Pch=[2600 2750 2800 2950 3010 3100 3300 3580 3750];
Pdis=[3450 3330 2900 1500 1200 850 300 22 -150];
Pch(Pch>Pmax | Pch<Pmin)=[];
Pdis(Pdis>Pmax | Pdis<Pmin)=[];
  4 件のコメント
Mamad Mamadi
Mamad Mamadi 2019 年 12 月 24 日
I wanted to send you some matlab codes and describ my problems in private LOL but no matter i will post it here. tnx anyway :)
Mamad Mamadi
Mamad Mamadi 2020 年 1 月 14 日
編集済み: Mamad Mamadi 2020 年 1 月 14 日
Hi Rik could you please help me in these codes?
i=1:8784 %one year (hours)
if Ppv_N(i,1) > PLoad(i,1);
Pch(1,i)=(Pbat*(1-sigma))+(Ppv_N(i,1)-(PLoad(i,1))/eta_i)*eta_b;
else Ppv_N(i,1) < PLoad(i,1)
Pdis(1,i)=(Pbat*(1-sigma))-((PLoad(i,1)/eta_i)-Ppv_N(i,1));
now after finding Pch and Pdis from 1 to 8784 hours, i want to write another code to solve 'a' as i mentioned below for example ;
when (Pch & Pdis)=0 %at the same time when both Pch and Pdis become zero, then
a=PLoad(i,1) - Ppv_N(i,1)
thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDictionaries についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by