find index of value in array

2 Ansichten (letzte 30 Tage)
Elif KORKMAZ
Elif KORKMAZ am 30 Okt. 2021
Bearbeitet: DGM am 30 Okt. 2021
hello, how can I find which numbers in a matrix are less than x and then print another number instead of the number I found?

Antworten (1)

DGM
DGM am 30 Okt. 2021
Bearbeitet: DGM am 30 Okt. 2021
A = randi(99,10,10) % test array
A = 10×10
11 29 88 59 64 59 20 49 53 65 60 75 47 68 47 69 2 43 13 46 37 70 50 17 82 37 64 72 86 75 33 13 2 76 57 66 74 76 10 99 53 9 79 5 62 83 8 46 94 83 47 58 88 62 79 36 5 56 57 53 88 4 19 64 49 53 22 25 98 90 18 79 23 97 34 47 41 42 38 53 51 93 3 94 78 45 32 5 39 14 44 16 58 26 77 94 8 89 50 34
x = 30;
lessthanx = A(A<x) % all the numbers in A that are < x
lessthanx = 25×1
11 18 29 13 9 4 16 2 19 23
fprintf('%d',randi(1000,1,1)) % "print another number instead of the number I found"
463

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by