Using the find function

1 Ansicht (letzte 30 Tage)
Anthony
Anthony am 20 Apr. 2012
A= magic(4)
for z= 1:4
position(z) = find(A(:,z)>10,1)
end
I want to use the find function to find all the values greater than 10 . this will enable me use the command A(position) to get all the values greater than 10 in a matrix. Is this possible with matlab?

Akzeptierte Antwort

Thomas
Thomas am 20 Apr. 2012
A= magic(4)
[row,col]=find(A>10)
should give you all positions of values in a Which are > 10
To find the actual values in A which are > 10 use
A(A>10)
ans =
16.00
11.00
14.00
15.00
13.00
12.00

Weitere Antworten (1)

Anthony
Anthony am 20 Apr. 2012
Thank you Thomas. The reason I am looking for the position is because I want to use these positions to access other values in a matrix named Zone. Zone is defined by: Zone = [3 5 7 9; 4 7 8 2; 4 6 7 8; 5 1 3 2]
So how do I relate the positions from A to the values I want in Zone? basically what I want from Zone is [3,7,1,3,9,8]. Is this possible?
  1 Kommentar
Thomas
Thomas am 20 Apr. 2012
Zone(A>10)
should do the trick..

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by