LINPROG requires the following inputs to be of data type double: 'f'.
조회 수: 3 (최근 30일)
이전 댓글 표시
%% Discrete modelling
Ae=(1-(K*ts)/Cth);
B=(ts*COP*HP)/Cth;
D=ts*K/Cth;
u=zeros(1,i);
Tin=zeros(1,i);
x=zeros(3,i);
cost=[gamma;zeros(1,1008);zeros(1,1008)];
xcost=zeros(3,i);
for j=1:i
if j>1
Tin(j)=Ae*Tin(j-1)+B*u(j-1)+C*Tout(j-1);
x=[u(j-1);Tin(j-1);gamma(j-1)];
else
Tin(j)=0;
u(j)=0;
x(j)=0;
end
% x=[u(j);Tin(j);gamma(j)];
cost=[gamma(j);0;0];
f=@(x) sum(cost(j).'*x(j));
%Starting point%
x0=0;
%Constraints%
%Inequality const%
A=[1 0 0;-1 0 0;0 1 0;0 -1 0;0 0 1;0 0 -1];
b=[umin; -umax; Tmin; -Tmax; gammamin; -gammamax];
options = optimoptions(@linprog,'Display', 'off');
[x(j),xcost(j)]=linprog(f,x0,A,b);
end
답변 (1개)
Ameer Hamza
2020년 10월 18일
편집: Ameer Hamza
2020년 10월 18일
linprog() does not require you to multiply 'f' with x. It will do that internally. Just directly give the vector 'f'
f = cost; % instead of f = @(x) sum(cost(j).'*x(j));
댓글 수: 2
Ameer Hamza
2020년 10월 18일
The dimensions of A and b seem to be fine? Can you add a breakpoint and see if the dimensions are correct when the issue happens?
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!