How to randomly change a digit in a string
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a string = 00101 How i can randomly change one digits of that string? Ex: 00101=>00100
댓글 수: 0
채택된 답변
Joseph Wilson
2020년 12월 22일
string1 = '00101';
digit_change = randi(length(string1));
digit_val = str2num(string1(digit_change));
digit_new = num2str(~digit_val);
string1(digit_change)=digit_new;
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!