how to return only true statements

조회 수: 2 (최근 30일)
Tristan
Tristan 2013년 9월 27일
댓글: Azzi Abdelmalek 2013년 9월 27일
for example, if I have:
>> e=[1 -7 -1.2 6 -9 19 1.8]
and I want matlab to give me only the true statements for e>0
as in:
e=[1 6 19 1.8]
I tried
>> if e>0 e end
but doesn't do anything.
thanks
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 27일
편집: Azzi Abdelmalek 2013년 9월 27일
I think you should read the basics of programming. (not necessary Matlab)
if e>0
e
end
What are you expecting when you write
e

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

채택된 답변

Image Analyst
Image Analyst 2013년 9월 27일
You mean like this
out = e(e>0)

추가 답변 (1개)

Wayne King
Wayne King 2013년 9월 27일
Just do
e>0
You get the following
1 0 0 1 0 1 1
If you want to return the elements
X = e(e>0);

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by