Need to calculate the power of battery

조회 수: 3(최근 30일)
Ajit Bashyal
Ajit Bashyal 2021년 3월 4일
댓글: Ajit Bashyal 2021년 3월 18일
Hello there,
Please kindly help me to write the matlab function code to calculate the power of the battery. Actually, the problem is that I have the I have a cost function whose output is battery power and there are several inputs. But the equation to calculate the input variables also depend on the output of previous time which is currently unknown. I can give you some example here:
function [X(t)]=batterypower(a(t)+b(t)+c(t)+d(t))
where t=0:100 %time
I used for loop but still cannot get the result.
This is just the example but my problem is also similar. As we can see the input variable also depend on past output variable which is not yet calculated. How can write this in matlab function code. If anybody can help me, please I would be very thankful to him/her.
If you require my equation and given data, I would share that too. Please help me.


Prudhvi Peddagoni
Prudhvi Peddagoni 2021년 3월 8일
You can create arrays beforehand and try to fill it from t = 1 to 100.
a = zeros(1,100);
b = zeros(1,100);
c = zeros(1,100);
d = zeros(1,100);
X = zeros(1,100);
a(1) = 1;
b(1) = 1;
c(1) = 1;
d(1) = 1;
X(1) = 1;
for i = 1:100
[a,b,c,d,X] = batterypower(a,b,c,d,X,i);
function [a,b,c,d,X] = batterypower(a,b,c,d,X,t)
Hope this helps.
  댓글 수: 1
Ajit Bashyal
Ajit Bashyal 2021년 3월 18일
Thank you for your informative response. This helps a lot to solve my problem.

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

Community Treasure Hunt

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

Start Hunting!

Translated by