finding location of numbers in matrix

1 回表示 (過去 30 日間)
sisay
sisay 2013 年 7 月 17 日
I have a matrix of A= 65 x 500. I want to find the position (location) of data in 'A' which are above 300. It really giving me trobles can somebody help me with this?
I tried this but with no avail. Btw. the number of datapoints which are above 300 varies among rows.
for jj= 1:size(A,1)
[ i j]= find(A>300);
end
And this gives only the total number of data points. Not row wise. Any help

回答 (4 件)

Andrei Bobrov
Andrei Bobrov 2013 年 7 月 17 日
A=[2 3 4; 3 2 2 ;5 6 7]
[ii,jj]=find(A'>2)
out = accumarray(jj,ii,[],@(x){x'})
  1 件のコメント
Ede gerlderlands
Ede gerlderlands 2013 年 7 月 17 日
Thank you. It works

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


the cyclist
the cyclist 2013 年 7 月 17 日
編集済み: the cyclist 2013 年 7 月 17 日
Just this one line gives all the (i,j) coordinates, for all rows.
[i j]= find(A>300);
So, if you are interested in row 7 (for example), then find where i=7, and look at the corresponding values of j.
If you absolutely must do it separately for each row (for reasons you do not explain here), then you could do
for ii= 1:size(A,1)
j{ii} = find(A(ii,:)>300);
end
The ii th element of the cell array will have the indices for row ii.
  2 件のコメント
Ede gerlderlands
Ede gerlderlands 2013 年 7 月 17 日
編集済み: Ede gerlderlands 2013 年 7 月 17 日
To put it simpler . If I have A=[2 3 4; 3 2 2 ;5 6 7] and If I want the location of points for A>2 for each row. What I expect is for each row is something like this
2 3
1
1 2 3
Ede gerlderlands
Ede gerlderlands 2013 年 7 月 17 日
Thank you I have got it...

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


Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 17 日
[ii,jj]=find(A>300)
  2 件のコメント
Ede gerlderlands
Ede gerlderlands 2013 年 7 月 17 日
編集済み: Ede gerlderlands 2013 年 7 月 17 日
Thank you .This gives the position of total number of data points which are greater than 300. Not the position within each row.
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 17 日
for k=1:size(A,1)
idx{k}=find(A(k,:)>300)
end

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


Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 17 日
id=arrayfun(@(x) find(A(x,:)>300),(1:size(A,1))','un',0)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by