필터 지우기
필터 지우기

conditional representation of logical numbers

조회 수: 1 (최근 30일)
Tino
Tino 2021년 6월 3일
댓글: Tino 2021년 6월 4일
Hello
Please I have the following time series { 111110011111000000011000011111} in time interval of seconds.
I want to use the following conditions on the sequence. Assuming 1 = True and 0 = false
if false is < 3 seconds and are inbetween two "true periods" then it is translated as 1
if true is < 3 seconds they are translated into 0
The answer when the condition is applied is
11111111111100000000000011111
I will be grateful if anyone assist me in writing this code
Thanks in advance
  댓글 수: 4
Walter Roberson
Walter Roberson 2021년 6월 4일
But is 11100111 to be translated to 1111111 (the run is converted to a single 1), or is 11100111 to be translated to 11111111 (each 0 is to be translated to a 1) ? Your example result used both possibilities.
Tino
Tino 2021년 6월 4일
Hi Walter
Yes the possibility of both is implemented. In the first instance you gave
the 11100111 because zeros is surrounded by 1 then the new sequence is 11111111 ( 11 is converted to 00)
For the second instance 11100111 because it is surrounded by zeros and less than 3 length it is converted to 11 (00 is converted to 11)
Hope it is clear Walter

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

채택된 답변

David Hill
David Hill 2021년 6월 3일
a='111110011111000000011000011111';
a=strrep(a,'1001','111');
a=strrep(a,'101','111');
a=strrep(a,'010','000');
a=strrep(a,'0110','000');
  댓글 수: 3
Stephen23
Stephen23 2021년 6월 4일
@Tino: try these:
b = a=='1'
b = a-'0'
Tino
Tino 2021년 6월 4일
Thanks Stephen

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by