0
  1. How to use mod() to create a mask of where A contains an even number? C =

  2. How to replace values with a mask. Using your mask, C, assign the even values in var1 into the corresponding values of var2. D =

  3. Use 'and' and 'or' to find a mask of where both A and C were true. E =

Thank You.

Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129
Jason Thapa
  • 123
  • 9

1 Answers1

0

This is all very basic MATLAB.

(1)

A = [7 8 10 11 13 18];

C = mod(A, 2)==0;

A(find(C))

(2)

var1 = zeros(20,1);
var2 = A;
var1(find(C)) = var2(find(C));

(3)

C = (mod(A,2)==0);
D = (mod(A,3)==0);

A(find(C|D))

A(find(C&D))
carlosdc
  • 12,022
  • 4
  • 45
  • 62