0

I need to check in an array all cells with a value under 9. I build an array with the indexes of those cells using find.

So I have for example array of values

A = [ 2, 10, 3 ]

and array of index

B = [ 1, 3 ]

then I need to set in a new C array the value of index 1 and 3 to 7. How can I do this without a loop?

Cher
  • 2,789
  • 10
  • 37
  • 64

1 Answers1

0

You can do this to replace values at certain indices.

C = ones(7,1);
C( [1 3 4 5 6 7] ) = [1 2 3 4 5 6]
karakfa
  • 66,216
  • 7
  • 41
  • 56