Element change in a matrix
조회 수: 12 (최근 30일)
이전 댓글 표시
Hello,
I would like to know if its is possible to subtitute elements in a matrix by conditions. Imagine a matrix in where there are number between 1-100, i want to set all value that are under 30 to 0, all between 30 and 75 to 1 and between 75 and 100 to 2, how do i do it? is that even possible? thank you
댓글 수: 0
채택된 답변
KSSV
2021년 4월 5일
편집: KSSV
2021년 4월 5일
Let A be your matrix.
B = A ;
B(B<30) = 0 ; % replace < 30 to 0
B(B>=30 && B<75) = 1 ;
댓글 수: 2
KSSV
2021년 4월 5일
@Ricardo jose commented:
Uau, it really worked.
Damn im so gratefull, thank a lot, you saved me ahah.
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Choose and Parameterize Blocks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!