フィルターのクリア

condition checking in matlab

8 ビュー (過去 30 日間)
subha
subha 2013 年 11 月 3 日
コメント済み: subha 2013 年 11 月 3 日
i want to verify each element in the matrix and keep that value in the same place if its true otherwise i want to make it as 0.
example: say x=[0.1 0.2 0.3;0.4 0.5 0.6;0.7 0.8 0.9]
i want to check two condition 1.Y=x>0 &x<0.25 2.Z=x>0.25 & x<0.5
i want both Y and Z to be in same size.so,want to add zeros in all the other locations where condition is not satisfied.Can anybody help?
i used ind=find(x>0)&(x<0.25) and then y(ind). but it produces an array.how to get matrix of size x with added zero in remaining all places.

採用された回答

the cyclist
the cyclist 2013 年 11 月 3 日
Here's one way:
ind = (x>0)&(x<0.25);
y = ind.*x;
  1 件のコメント
subha
subha 2013 年 11 月 3 日
thanks

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 3 日
x=[0.1 0.2 0.3;0.4 0.5 0.6;0.7 0.8 0.9]
y=zeros(size(x))
z=y;
idy=x>0 & x<0.25
idz=x>0.25 & x<0.5
y(idy)=x(idy)
z(idz)=x(idz)
  1 件のコメント
subha
subha 2013 年 11 月 3 日
thanks all for your valuable reply

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

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by