Azzera filtri
Azzera filtri

Using the find function

1 visualizzazione (ultimi 30 giorni)
Anthony
Anthony il 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?

Risposta accettata

Thomas
Thomas il 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

Più risposte (1)

Anthony
Anthony il 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 Commento
Thomas
Thomas il 20 Apr 2012
Zone(A>10)
should do the trick..

Accedi per commentare.

Categorie

Scopri di più su Simulink in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by