How to replace 0 value with 3 in Matlab
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, I hope you are doing well, I am trying to do two thing.
1. Find the number exist in fifth column of data e.g 0,1,2
2. Replace the 0 value in fifth column to 3
댓글 수: 0
답변 (1개)
KSSV
2022년 12월 2일
c5 = Dataset(:,5) ;
% Find the number of 0, 1, 2
idx = c5 == 0 | c5 == 1 | c5 == 2 ; % gives logical indices
nnz(idx) % this gives total number
% Replace 0 with 3
c5(c5==0) = 3 ;
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!