フィルターのクリア

Why I am i getting a negative value for the spread when i restricted it have positive values.?I would be glad if anyone could help.

1 回表示 (過去 30 日間)
clear all
clc
IN=[-0.04844752 0.041968141 -0.044564664;
-0.304020248 0.131284505 0.472041681;
-0.074829705 -0.049999997 -0.094350919;
0.28895241 0.390694469 0.416666657;
-0.098011374 0.012270158 -0.067317739;
-0.175849974 -0.160909101 -0.174713209;
-0.141403094 -0.004999995 -0.098300003;
-0.210274339 -0.191784486 -0.109999985
]
OUT=[-0.148966655;
0.281067416;
-0.154999971;
0.360221535;
-0.120833755;
-0.18519102;
-0.136289001;
-0.184634596 ]
h=0.2
p=1-h
NEWIN=[ones(size(IN,1),1) IN]
num_NEWIN=size(NEWIN,2)
D=zeros(num_NEWIN,num_NEWIN)
E=(-1).*eye(num_NEWIN,num_NEWIN)
B=zeros(num_NEWIN,1)
A=[-NEWIN -p*abs(NEWIN); NEWIN -p*abs(NEWIN); D E]
b=[-OUT; OUT; B]
v1=sum(abs(NEWIN(:,1)))
v2=sum(abs(NEWIN(:,2)))
v3=sum(abs(NEWIN(:,3)))
v4=sum(abs(NEWIN(:,4)))
f=[zeros(num_NEWIN,1);v1;v2;v3;v4]
%f=[zeros(num_NEWIN,1);ones(num_NEWIN,1)]
x=linprog(f,A,b)
Center_coeff= x(1:4,1)
spread_coeff= x(5:8,1)

採用された回答

Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro 2018 年 7 月 5 日
Just ran your code and had this:
spread_coeff =
0.0452
0
0
0
No negatives
  1 件のコメント
Honey Adams
Honey Adams 2018 年 7 月 5 日
for some values of h.. it gives me negatively.I have defined bounds for the problem.lb and ub.It worked.

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

その他の回答 (1 件)

カテゴリ

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