How to solve "Check for incorrect argument data type or missing argument in call to function 'exp'" in matrix for linear program

조회 수: 45 (최근 30일)
I'm trying to set up the matrices for my linear program to simulate the usage of distibuted energy resources in a microgrid.
When setting up the matrices I get the following error message (I also attached an example of the simulated price data):
Check for incorrect argument data type or missing argument in call to function 'exp'.
Error in (line 91)
f=[OMVar_L+(exp(Y(n,T))*Phi+FTDCharge)/EEff_L; (exp(X(n,T))+ETDCharge); (exp(Y(n,T))*Phi+FTDCharge)/HEff; 0;
EDRCost; HDRCost];
I don't understand why I'm getting this error which is why every help is much appreciated.
Code Extract:
% Test file
...
N = 365; % number of sample paths
T = 365; % number of decision-making steps
h = 24; % number of hours per day
Phi = 3.412; % conversion factor from MMBTU to MWh (MMBTU/MWh)
...
% length of time step in years
dt = 1/T;
% demand data
ED=zeros(T,1);
HD=zeros(T,1);
ED=readtable('ED.xls');
HD=readtable('HD.xls');
% periodic discount factor
Beta = exp(-r*dt);
% generate N correlated sample paths for X and Y
X = zeros(N,T);
Y = zeros(N,T);
X=readtable('Simulated Log Electricity Prices Test');
Y=readtable('Simulated Log Gas Prices Test');
for n=1:N
% define objective function coefficients
f=[OMVar_L+(exp(Y(n,T))*Phi+FTDCharge)/EEff_L; (exp(X(n,T))+ETDCharge); (exp(Y(n,T))*Phi+FTDCharge)/HEff; 0; EDRCost; HDRCost];
% define inequality constraint coefficients and rhs
A=[1 0 0 0 0 0
-HR_L 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1];
b=[G_L*h; 0; MaxEDR*ED(T); MaxHDR*HD(T)];
% define equality constraint coefficients and rhs
Aeq=[1 1 0 0 1 0
0 0 1 1 0 1];
beq=[ED(T); HD(T)];
% set lower-bound constraints on the decision variables
lb = zeros(6,1);
% solve the LP
[x fval] = linprog(f,A,b,Aeq,beq,lb);
Gen_L(n,T)=x(1);
EPurchase(n,T)=x(2);
NGHeat(n,T)=x(3);
DGHeat(n,T)=x(4);
EDResponse(n,T)=x(5);
HDResponse(n,T)=x(6);
V(n)=fval;
end
  댓글 수: 2
Jakeb Chouinard
Jakeb Chouinard 2021년 8월 3일
편집: Jakeb Chouinard 2021년 8월 3일
We will need to understand what the files look like that you're trying to read the table from. It is possible that your indexing for the table is referring to the wrong location or to something that is being stored as a char rather than a double, which would cause the exp function to fail.

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

채택된 답변

Eike Blechschmidt
Eike Blechschmidt 2021년 8월 4일
편집: Eike Blechschmidt 2021년 8월 4일
The following returns a table.
X=readtable('Simulated Log Electricity Prices Test');
If you index it using the following a table is returned.
X(1,1)
The exp-function on the other hand is not defined for table input.
If you replace all
Y(n,T)
by
Y{n,T}
It should be working.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cash Flows에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by