close

In this example , we want to tell you how to replace specific number of array.

Assume we have follow matrix , and we want replace 0 to -1 ;

array = [0 3 1 5 6 0 0 1 4 7 9 0 0 0 4 5 3 0]

zero_loc = find(a == 0);

array(zero_loc) = -1;


the result of a will be :

array = [-1 3 1 5 6 -1 -1 1 4 7 9 -1 -1 -1 4 5 3 -1]

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JerryCheng 的頭像
    JerryCheng

    KwCheng's blog

    JerryCheng 發表在 痞客邦 留言(0) 人氣()