필터 지우기
필터 지우기

how to read and change entries in a large array

조회 수: 2 (최근 30일)
Daniel Hamilton
Daniel Hamilton 2018년 2월 26일
댓글: KL 2018년 2월 26일
I have a 842x650, i want to read through every entry, check its value and if its under a certain value change it to zero. Any help would be amazing !!

채택된 답변

KL
KL 2018년 2월 26일
It's easier to answer with an example. Let's say we have a matrix of 5x5 with random numbers and you want to find the elements that are between 0.5 and 0.75 and then make it to zero.
A = rand(5,5)
ind = A>=0.5 & A<=0.75;
A(ind) = 0;
A
and now an example result is (before and after),
A =
0.8001 0.1455 0.1450 0.4018 0.2400
0.4314 0.1361 0.8530 0.0760 0.4173
0.9106 0.8693 0.6221 0.2399 0.0497
0.1818 0.5797 0.3510 0.1233 0.9027
0.2638 0.5499 0.5132 0.1839 0.9448
A =
0.8001 0.1455 0.1450 0.4018 0.2400
0.4314 0.1361 0.8530 0.0760 0.4173
0.9106 0.8693 0 0.2399 0.0497
0.1818 0 0.3510 0.1233 0.9027
0.2638 0 0 0.1839 0.9448
  댓글 수: 1
KL
KL 2018년 2월 26일
I'd also recommend reading a bit about floating point numbers. Various threads with extensive explanations exist, probably start with this one: https://www.mathworks.com/matlabcentral/answers/57444-faq-why-is-0-3-0-2-0-1-not-equal-to-zero

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by