Extract a matrix out of another matrix with logiccal expression
Mostrar comentarios más antiguos
Hi
I have a matrix like F=[7 5;2 7;3 5;4 9;5 3;6 1;2 5;8 2;1 8;10 1]. I want to extract those rows in which the elements in column 1 are bigger than 5 like B=[7 5;5 3;6 1;8 2;10 1].
It would be better If I can do it with loop function like for or if.
Thank you in advance.
Amir
Respuesta aceptada
Más respuestas (1)
Andrei Bobrov
el 26 de Mayo de 2015
Your homework?
out = [];
for jj = 1:size(F,1)
if F(jj,1) >= 5
out = [out; F(jj,:)];
end
end
1 comentario
Amirhossein
el 26 de Mayo de 2015
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!