How to select some part of a matrix ?

12 vues (au cours des 30 derniers jours)
Rita
Rita le 8 Sep 2016
Commenté : mbonus le 8 Sep 2016
Hi,I have a matrix with two column I would like to select data from the second column based on the condition that I put for the first column.for example if I have
A=[ 32 5
38 4
43 6
49 3
53 13
59 34
61 2
64 23]
and I want to have this
if 43<A(:,1)<59 then give me the numbers of second column which are 3 and 13.(with the same row)
Thanks a lot

Réponse acceptée

mbonus
mbonus le 8 Sep 2016
b = A(:,1) > 43;
c = A(:,1) < 59;
d = b & c;
result = A(d,2)
  3 commentaires
Rita
Rita le 8 Sep 2016
Thank you so much for your help.
mbonus
mbonus le 8 Sep 2016
Glad to help

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by