convert cell of 'True' and 'False' values to a numeric array of 1s and 0s
조회 수: 118 (최근 30일)
이전 댓글 표시
i have a 6432 x 1 cell containing values of either 'True' or 'False'.
I'm trying to convert the cell to a numeric array with a value of 0 for False and 1 for True.
I must be missing an obvious solution, but I feel like I've tried everything.
I've attached the cell array here.
Thank you.
댓글 수: 0
답변 (4개)
Steven Lord
2021년 10월 8일
s = {'true', 'false'};
C = s(randi(numel(s), 5, 5))
L = matches(C, 'true')
This same works if you wanted to use a string array.
ST = string(C)
LST = matches(ST, 'true')
댓글 수: 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!