MATLAB Answers

How to make this?

1 view (last 30 days)
Gemalyn Apostol
Gemalyn Apostol on 25 Oct 2016
Answered: KSSV on 25 Oct 2016
We create a vector z = ones(1,10);and define some intervals of z to be zero. The intervals are stored in vectors a and b where a contains the start indices and b the end indices of the intervals. With a = [3 8] and b = [5 9] the desired result should be r = [1 1 0 0 0 1 1 0 0 1].How do we make this?

  0 Comments

Sign in to comment.

Accepted Answer

KSSV
KSSV on 25 Oct 2016
z = ones(1,10);
a = [3 8] ;
b = [5 9] ;
for i = 1:length(a)
z(a(i):b(i)) = 0 ;
end

  0 Comments

Sign in to comment.

More Answers (0)