Azzera filtri
Azzera filtri

Exchanging negative values in a matrix with 0

18 visualizzazioni (ultimi 30 giorni)
Is it possible to replace all the negative values in this matrix with zeros?
matrix = 71.7231000000000 74.7231000000000 33.9028000000000 36.9028000000000
87.0232250000000 90.0232250000000 45.6629000000000 48.6629000000000
102.113350000000 105.113350000000 132.513550000000 135.513550000000
117.333450000000 120.333450000000 205.214100000000 208.214100000000
150.103700000000 153.103700000000 235.264350000000 238.264350000000
165.233825000000 168.233825000000 309.764825000000 312.764825000000
189.854025000000 192.854025000000 368.645250000000 371.645250000000
219.944225000000 222.944225000000 398.475450000000 401.475450000000
250.084425000000 253.084425000000 413.505550000000 416.505550000000
264.904525000000 267.904525000000 433.975675000000 436.975675000000
279.544650000000 282.544650000000 540.436375000000 543.436375000000
294.434750000000 297.434750000000 571.176575000000 574.176575000000
322.934950000000 325.934950000000 677.397250000000 680.397250000000
337.845050000000 340.845050000000 738.627625000000 741.627625000000
353.095150000000 356.095150000000 769.227800000000 772.227800000000
383.445350000000 386.445350000000 818.788100000000 821.788100000000
449.015775000000 452.015775000000 833.818200000000 836.818200000000
463.985900000000 466.985900000000 848.848300000000 851.848300000000
479.246000000000 482.246000000000 878.928450000000 881.928450000000
494.436075000000 497.436075000000 900.818575000000 903.818575000000
510.076250000000 513.076250000000 931.908775000000 934.908775000000
524.936375000000 527.936375000000 962.268975000000 965.268975000000
555.466475000000 558.466475000000 1009.10922500000 1012.10922500000
586.176700000000 589.176700000000 1054.06947500000 1057.06947500000
601.296775000000 604.296775000000 1116.57982500000 1119.57982500000
616.296875000000 619.296875000000 1131.61990000000 1134.61990000000
631.666950000000 634.666950000000 1146.64997500000 1149.64997500000
647.077075000000 650.077075000000 1176.75015000000 1179.75015000000
662.277150000000 665.277150000000 1191.79022500000 1194.79022500000
692.367350000000 695.367350000000 1206.82032500000 1209.82032500000
707.527425000000 710.527425000000 1223.95042500000 1226.95042500000
722.557550000000 725.557550000000 1284.98075000000 1287.98075000000
753.667725000000 756.667725000000 1330.36100000000 1333.36100000000
784.257900000000 787.257900000000 1345.39107500000 1348.39107500000
802.008000000000 805.008000000000 1377.19125000000 1380.19125000000
863.588375000000 866.588375000000 1392.22132500000 1395.22132500000
915.848675000000 918.848675000000 1454.93165000000 1457.93165000000
946.878875000000 949.878875000000 1501.17190000000 1504.17190000000
978.249050000000 981.249050000000 1516.21197500000 1519.21197500000
993.469125000000 996.469125000000 1528.94205000000 1531.94205000000
1023.80932500000 1026.80932500000 1543.97212500000 1546.97212500000
1038.77940000000 1041.77940000000 1559.00220000000 1562.00220000000
1068.55957500000 1071.55957500000 1574.04227500000 1577.04227500000
1084.99965000000 1087.99965000000 -5 -2
1101.29975000000 1104.29975000000 -5 -2
1161.61007500000 1164.61007500000 -5 -2
1238.82050000000 1241.82050000000 -5 -2
1253.75060000000 1256.75060000000 -5 -2
1269.20067500000 1272.20067500000 -5 -2
1298.59082500000 1301.59082500000 -5 -2
1314.54090000000 1317.54090000000 -5 -2
1360.43115000000 1363.43115000000 -5 -2
1407.26140000000 1410.26140000000 -5 -2
1423.53150000000 1426.53150000000 -5 -2
1439.64160000000 1442.64160000000 -5 -2
1469.96172500000 1472.96172500000 -5 -2
1485.48182500000 1488.48182500000 -5 -2

Risposta accettata

Image Analyst
Image Analyst il 28 Dic 2016
Here's another alternate way:
matrix = max(matrix, 0)

Più risposte (1)

Sean de Wolski
Sean de Wolski il 28 Dic 2016
  3 Commenti
Image Analyst
Image Analyst il 12 Feb 2020
Yes it does. Can you give a counterexample where it does not work?
Walter Roberson
Walter Roberson il 12 Ott 2022
You could argue that it is not changing negative 0

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by