How to ignore values in an array
이전 댓글 표시
I'm creating an array [array 1] that fulfills the formula (A - B/C), where A and B are matrices with different elements and C is a matrix with a constant value. I then want to make another array [array 2] which is dependent on the values obtained from the formula in array 1.
So in array 2, I want it to check for values greater than 0.5 and set those to 0, and values less than or equal to 0 to be set to 1.
However, as A and B both begin at a value of 0; the first element in array 1 will be 0, making the first element of array 2 1.
How could I ignore this value?
I've currently made array 2 by doing:
A_2 = (A_1<= 0.5 & A_1>=0)
댓글 수: 1
dpb
2017년 12월 23일
I couldn't tell what you want the end result to be, sorry. Give us a really small example input/output as illustration.
채택된 답변
추가 답변 (1개)
Image Analyst
2017년 12월 23일
Try this:
a2 = A1; % Initialize
zerosMask = a2 > 0.5;
a2(zerosMask) = 0;
onesMask = a2 < 0;
a2(onesMask) = 1;
카테고리
도움말 센터 및 File Exchange에서 Crystals에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!