finding location of numbers in matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (4)
Andrei Bobrov
el 17 de Jul. de 2013
A=[2 3 4; 3 2 2 ;5 6 7]
[ii,jj]=find(A'>2)
out = accumarray(jj,ii,[],@(x){x'})
1 comentario
the cyclist
el 17 de Jul. de 2013
Editada: the cyclist
el 17 de Jul. de 2013
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 comentarios
Ede gerlderlands
el 17 de Jul. de 2013
Editada: Ede gerlderlands
el 17 de Jul. de 2013
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
el 17 de Jul. de 2013
[ii,jj]=find(A>300)
2 comentarios
Ede gerlderlands
el 17 de Jul. de 2013
Editada: Ede gerlderlands
el 17 de Jul. de 2013
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
el 17 de Jul. de 2013
for k=1:size(A,1)
idx{k}=find(A(k,:)>300)
end
Azzi Abdelmalek
el 17 de Jul. de 2013
id=arrayfun(@(x) find(A(x,:)>300),(1:size(A,1))','un',0)
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!