finding location of numbers in matrix
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(4 个)
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
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
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
2013-7-17
[ii,jj]=find(A>300)
2 个评论
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!