필터 지우기
필터 지우기

How to apply the condition on data?

조회 수: 2 (최근 30일)
Noor Fatima
Noor Fatima 2022년 3월 28일
댓글: Noor Fatima 2022년 3월 28일
I have arrays of binary numbers
I want to remove leading zeros
A = ['1001','0010','0']
B= '10101'
for i=1:3
a1 = A(i);
a2= regexprep(a1,'^0*','');
a3 = B(1:length(a2))
result = a2~=a3
end
For third entry of A , A(3)='0', I get empty output due to regexprep(a1,'^0*','');, but I want to apply condition or any other way so that if any entry of A in only zero then exclude this condition regexprep(a1,'^0*','');, so that for A(3)='0' , I can get a2=0, a3=1 and result=1
  댓글 수: 4
KSSV
KSSV 2022년 3월 28일
A(1)='1001' ;output=0011 or 1001?
A(3) = '0', output =1 or 0 ?
Noor Fatima
Noor Fatima 2022년 3월 28일
A(1)='1001' ;output=0011 or 1001? 0011
(a1=1001, a3=1010, ans = '1001' ~='1010'=0011)
Like for A(3) output is 1

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by