LINPROG requires the following inputs to be of data type double: 'f'.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
%% 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
Risposte (1)
Ameer Hamza
il 18 Ott 2020
Modificato: Ameer Hamza
il 18 Ott 2020
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 Commenti
Ameer Hamza
il 18 Ott 2020
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?
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!