Extract a matrix out of another matrix with logiccal expression

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

 채택된 답변

Thorsten
Thorsten 2015년 5월 26일
F(F(:,1) >= 5, :);

댓글 수: 1

thank you for your quick answer. is it possible that I code it with loop function?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2015년 5월 26일
Your homework?
out = [];
for jj = 1:size(F,1)
if F(jj,1) >= 5
out = [out; F(jj,:)];
end
end

댓글 수: 1

Thank you very much. Actually I am beginner in Matlab but it is not homework.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2015년 5월 26일

댓글:

2015년 5월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by