フィルターのクリア

LINPROG requires the following inputs to be of data type double: 'f'.

10 ビュー (過去 30 日間)
Ricardo López
Ricardo López 2020 年 10 月 18 日
コメント済み: Ameer Hamza 2020 年 10 月 18 日
%% 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
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 件のコメント
Ricardo López
Ricardo López 2020 年 10 月 18 日
I am still getting this error: The number of rows in A must be the same as the number of elements of b.
And I also tried to solve this by fmincon with f = @(x) sum(cost(j).'*x(j));
Ameer Hamza
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?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMuPAD についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by