how is it possible to solve below matlab codes problem?

조회 수: 1 (최근 30일)
Mamad Mamadi
Mamad Mamadi 2020년 1월 14일
편집: Mamad Mamadi 2020년 1월 15일
Hi everybody 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;
a=Ppv_N(i,1) - PLoad(i,1)
end
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 or loop to solve 'b' between 1:8784 , for example ;
when (Pch & Pdis)=0 %at the same time when both Pch and Pdis become zero, then
b=PLoad(i,1) - Ppv_N(i,1)
  • which i mean when Pch and Pdis at the same time became zero then use b=PLoad(i,1) - Ppv_N(i,1)
thanks

답변 (1개)

David Hill
David Hill 2020년 1월 14일
I was somewhat confused with your question. Hopefully, this helps:
for 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;
a=Ppv_N(i,1) - PLoad(i,1);
elseif Ppv_N(i,1) < PLoad(i,1)
Pdis(1,i)=(Pbat*(1-sigma))-((PLoad(i,1)/eta_i)-Ppv_N(i,1));
end
end
b=[];
for i=1:8784
if Pch(1,i)==Pdis(1,i)
b=[b,PLoad(i,1) - Ppv_N(i,1)];%not sure if you will have more than one occurrance
end
end
  댓글 수: 3
David Hill
David Hill 2020년 1월 15일
Is that not that what I did?
Mamad Mamadi
Mamad Mamadi 2020년 1월 15일
편집: Mamad Mamadi 2020년 1월 15일
i ran your codes but didnt work it showed an error.
Attempted to access Pch(1,1); index out of bounds
because size(Pch)=[0,0].
i dont know how to solve this error.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by