I want to minimaze with the arrays that follow with the command linprog.

1 回表示 (過去 30 日間)
marios semer
marios semer 2020 年 12 月 10 日
コメント済み: Matt J 2020 年 12 月 10 日
Hello, what should i choose for f array if my y1=A and D1=b ( I want only for inequality ).
clc ;
clear all ;
close all ;
% % N = input('Tell me the length N: ' );
N = 25;
K = N + 1 ;
w = linspace( 0 , pi , 10*K);
w=w';
D1= ones( 2*length(w),1);
W1= ones( 2*length(w),1);
for i = 1:1:length(w)
if w(i)>= 0.4*pi
h = 2*i;
break;
end
end
for i = 2:2:length(w)
D1(i)= -1;
end
for h = h:length(D1)
D1(h)= 0;
W1(h) = 2;
end
% for i = 2:2:2*length(w3)
% W1(i)= -1*W1(i);
% end
y1 = zeros( length(D1) , K+1);
for i = 1:1:length(w)
for j = 1:1:K+1
y1(2*i-1,j) = 2*cos((j-1)*w(i));
y1(2*i-1,1) = 1;
y1(2*i,j) = -2*cos((j-1)*w(i));
y1(2*i,1) = -1;
y1(2*i-1,K+1) = 1/W1(2*i);
y1(2*i,K+1) = -1/W1(2*i);
end
end
D1 = D1';
f = ones( 1 , K+1);
% f(:,K+1)=1;
X = linprog(f,y1,D1)
Optimal solution found.
X = 27×1
-1.0000 0 0 0 0 0 0 0 0 0
  1 件のコメント
Matt J
Matt J 2020 年 12 月 10 日
It looks like your code runs and produces a solution. What are we supposed to see as a difficulty in what you've posted?

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

回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by