Hello,
I hope everyone is okay.
I have a question regarding a logical vector.
let's suppose I have the vector
d=0.1:0.1:0.6;
and I want to obtain a logical vector that meets this condition
N= d==0.4000 & d==0.1000 ;
The result of this operation has to be a vector like this
N=[0 0 0 1 0 1 ] 1x6 logical
Can someone here help me?
Thank you

 채택된 답변

Devanuj Deka
Devanuj Deka 2021년 7월 14일
편집: Devanuj Deka 2021년 7월 14일

1 개 추천

You can try this:
ismembertol(d,0.4) | ismembertol(d,0.6)
ismembertol is needed because the '==' logical operator might sometimes not give you the expected results when dealing with fractional data of type 'double'.

댓글 수: 2

Fidele Adanvo
Fidele Adanvo 2021년 7월 14일
Thank you
Devanuj Deka
Devanuj Deka 2021년 7월 14일
You're welcome.

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

추가 답변 (0개)

카테고리

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

질문:

2021년 7월 14일

댓글:

2021년 7월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by