MATLAB Answers

Naime
0

odd and even index in cell

Asked by Naime
on 23 Apr 2019
Latest activity Edited by KSSV
on 23 Apr 2019
Accepted Answer by KSSV
A={[113],[112],[42],[29],[113],[69],[86],[9],[0]};
B={[18],[14],[5],[39],[27],[11],[9],[7],[0]};
I want put even index in A to zero. New_A should be:
New_A={[113],[0],[42],[0],[113],[0],[86],[0],[0]}
Also put odd index in B to zero. New_B should be:
B={[0],[14],[0],[39],[0],[11],[0],[7],[0]};

  0 Comments

Sign in to comment.

1 Answer

KSSV
Answer by KSSV
on 23 Apr 2019
Edited by KSSV
on 23 Apr 2019
 Accepted Answer

A={[113],[112],[42],[29],[113],[69],[86],[9],[0]};
B={[18],[14],[5],[39],[27],[11],[9],[7],[0]};
A(2:2:end) = {0} ;
B(1:2:end) = {0} ;

  0 Comments

Sign in to comment.