How to replace values in a matrix?
조회 수: 8 (최근 30일)
이전 댓글 표시
Hello,
I am fairly new to MATLAB and I have a question. How do you replace a value in a matrix? So if I have a matrix A, where A=3,2,5,-6. How can I find, and replace all of the negative numbers with 0? So I want to end up with a matrix of 3,2,5,0.
Thank you!
Molly
댓글 수: 0
채택된 답변
Star Strider
2015년 9월 21일
One way is to use ‘logical indexing’:
A = [3,2,5,-6];
A(A<0) = 0
A =
3 2 5 0
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Analytics Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!