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 CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by