how to read and change entries in a large array
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 !!
0 Kommentare
Akzeptierte Antwort
KL
am 26 Feb. 2018
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 Kommentar
KL
am 26 Feb. 2018
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!