필터 지우기
필터 지우기

Please help me convert equation to matlab code.

조회 수: 1 (최근 30일)
ian adrian
ian adrian 2020년 7월 29일
답변: Alan Stevens 2020년 8월 2일
Deal all.
I need you to help turn this equation into matlab code
I spent a lot of time making it but it didn't work. thanks.
  댓글 수: 2
Sriram Tadavarty
Sriram Tadavarty 2020년 7월 29일
Hi Ian,
Can you post the code that you tried and what the issue was or what didn't work? From that equation it is not straight forward as what the values of each variable be.
Regards,
Sriram
ian adrian
ian adrian 2020년 8월 2일
clear
clc
pgridbuy = [3.3, 3.5, 3.2, 3.1, 3.6];
pgridsold = [2.3, 2.6, 3.1, 4.1, 4.4];
pricebuy = [2400, 2400, 2400, 2400, 2400];
pricesell = [1300, 1300, 1300, 1300, 1300];
deltatimebuy = [1, 1, 1, 1, 1];
deltatimesell = [1, 1, 1, 1, 1];
totalcost(pgridbuy, pricebuy, deltatimebuy, pgridsold, pricesell, deltatimesell);
function totalcost(pgridbuy, pricebuy, deltatimebuy, pgridsold, pricesell, deltatimesell)
TClist = [0, 0, 0, 0, 0];
for i = 1:length(TClist);
buy = pgridbuy(i) * pricebuy(i) / deltatimebuy(i);
sell = pgridsold(i) * pricesell(i) / deltatimesell(i);
TClist(i) = buy - sell
end
end

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

답변 (1개)

Alan Stevens
Alan Stevens 2020년 8월 2일
This does what you seemed to be trying to do::
pgridbuy = [3.3, 3.5, 3.2, 3.1, 3.6];
pgridsold = [2.3, 2.6, 3.1, 4.1, 4.4];
pricebuy = [2400, 2400, 2400, 2400, 2400];
pricesell = [1300, 1300, 1300, 1300, 1300];
deltaT = 1;
TC = sum(pgridbuy.*pricebuy - pgridsold.*pricesell )/deltaT;
disp(TC)
I assume that, in general, you will not want all the values of pricebuy and pricesell to be the same.

카테고리

Help CenterFile Exchange에서 Instrument Control Toolbox Supported Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by