Filter out negative values

19 ビュー (過去 30 日間)
Arjun
Arjun 2014 年 5 月 20 日
コメント済み: Sean de Wolski 2014 年 5 月 21 日
I have the following iterations running But how can I filter out the negative answer and the allow the program just to run on positive values
a=20000:5000:90000
for ct1=1:1:length(a)
b=300:20:460
for ct2=1:1:length(b)
c=150:10:300
for ct3=1:1:length(c)
d=0.5:0.1:0.8
for ct4=1:1:length(d)
e=2000:1000:2300
for ct5=1:1:length(e)
x(ct1,ct2,ct3,ct4,ct5)=a(ct1)+ b(ct2)- (c(ct3))^2 + d(ct4)+ e(ct5)
end
end
end
end
end

採用された回答

Matt J
Matt J 2014 年 5 月 20 日
編集済み: Matt J 2014 年 5 月 20 日
After x is generated,
x(x<0)=something;
  3 件のコメント
Matt J
Matt J 2014 年 5 月 20 日
After the loops are done,
y(x>=0)=x(x>=0)+32;
Arjun
Arjun 2014 年 5 月 21 日
編集済み: Arjun 2014 年 5 月 21 日
thanx alot fren....=)

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

その他の回答 (1 件)

Mahdi
Mahdi 2014 年 5 月 20 日
You can try using the subplus function.
For example, you would use
x(ct1,ct2,ct3,ct4,ct5)=subplus(a(ct1)+ b(ct2)- (c(ct3))^2 + d(ct4)+ e(ct5))
  2 件のコメント
Arjun
Arjun 2014 年 5 月 20 日
ok let say the next function is y = x +32; but I wan only the positive value of x to go in the calculation.....each time the iteration above gives negative value of x it won't be used in order to calculate y.
Sean de Wolski
Sean de Wolski 2014 年 5 月 21 日
Learn something new every day.

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

カテゴリ

Help Center および File ExchangeDigital Filter Design についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by