フィルターのクリア

If condition without loop

2 ビュー (過去 30 日間)
manokaran manivasakan
manokaran manivasakan 2012 年 6 月 28 日
i want to change as if 0<A(i,j)<=1 then 1 and if 1<A(i,j)<=2 then 2 and......i don't like to use loop.only use routing and chopping methods....

回答 (3 件)

Walter Roberson
Walter Roberson 2012 年 6 月 28 日

Jan
Jan 2012 年 6 月 28 日
if 0 < A(i,j) && A(i,j) <= 1
Please note, that if depending on the data it is not required to check 1 < A(i,j) again, when A(i, j) <= 1 has been excluded before (and no A < 0 cases appear).

Ryan
Ryan 2012 年 6 月 28 日
編集済み: Ryan 2012 年 6 月 28 日
A(A>0 & A<=1) = 1;
A(A>1 & <=2) = 2;
Of course if you'd like to do this continuously (constantly rounding values, not just between [0 1] and [1 2]) then use Walter Roberson's method for speed and ease of implementation.

製品

Community Treasure Hunt

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

Start Hunting!

Translated by