I have Matrix called A and I want to check the value of this Matrix. if the value is between 1 to 100 I want insert the cordinate of the value to Matrix B.
example:
A:
0 -1 5 12 6
0 -1 123 1 3
B:
1 1 1 2 2
3 4 5 4 5
How can I do this?

 採用された回答

dpb
dpb 2016 年 1 月 2 日

1 投票

>> [i j]=ind2sub(size(A),find(iswithin(A,1,100)));
>> [i j]
ans =
1 3
1 4
2 4
1 5
2 5
>>
iswithin is my utility helper function...
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
% dpbozarth
flg= (x>=lo) & (x<=hi);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

質問済み:

2016 年 1 月 2 日

回答済み:

dpb
2016 年 1 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by