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'})

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

请先登录,再进行评论。


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
id=arrayfun(@(x) find(A(x,:)>300),(1:size(A,1))','un',0)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by