フィルターのクリア

sum of coefficients less than 1

3 ビュー (過去 30 日間)
dav
dav 2013 年 3 月 3 日
Can someone please modify the following code so that it has a constraint that the sum of ar1 and ar2 is less than one.
Thanks
clc;
clear;
m=2;
a0 = 0.1; a1 = 0.2; a2=0.15;
epsi=zeros(3000,1);
simsig=zeros(3000,1);
for i = 1:3000
if (i==1)
simsig(i) = a0/(1-a1-a2) ;
s=(simsig(i))^0.5;
epsi(i) = normrnd(0,1) * s;
elseif (i==2)
epsi(i)=epsi(1);
else
simsig(i) = a0+ a1*(epsi(i-1))^2+a2*(epsi(i-2))^2;
s=(simsig(i))^0.5;
epsi(i) = normrnd(0,1) * s;
end
end
yt1=epsi.^2;
ytlast=epsi(3000)^2;
ytlast2=epsi(2999)^2;
ytinitial=yt1(2001:3000);
yt = yt1(2003:3000);
ytlag1= yt1(2002:2999);
ytlag2= yt1(2001:2998);
a =ones(1000-m,1);
x = [a,ytlag1,ytlag2];
opts = optimset('lsqnonneg');
opts.LargeScale = 'off';
opts.Display = 'none';
coef = lsqnonneg(x,yt);
alpha0 =coef(1);
ar1=coef(2);
ar2= coef(3);

採用された回答

Shashank Prasanna
Shashank Prasanna 2013 年 3 月 3 日
Do you have the optimization toolbox? LSQNONNEG cannot handle constraints.
Also, please format your code when you post. It makes it easier to read code. You can select your code and use the '{}Code' button.
  9 件のコメント
Teja Muppirala
Teja Muppirala 2013 年 3 月 5 日
To make coeff(2) + coeff(3) < 1, you can call LSQLIN like this:
coeff = lsqlin(x,yt,[0 1 1],[1],[],[],[0;0;0],[1;1;1])
See the help for LSQLIN
dav
dav 2013 年 3 月 5 日
Thanks alot everyone!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Least Squares についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by