jeudi 6 octobre 2016

Change the element in a matrix based on the value of the corresponding element in another matrix

First of all I want to generate a random matrix which size is the same as the input matrix. If an element value in random matrix is greater than 0.5 , then l have to increment the value of corresponding element in the input matrix by one, else decrement by 1.

X=[4       5        6  ;    7       8        9   ;     3        2       1]
Random=[ 0.65     0.43     0.23   ;       0.75     0.12      0.78  ;    0.31     0.96       0.58] 
Y= [ 5      4       5   ;    8       7     10  ;     2      3     2]




Aucun commentaire:

Enregistrer un commentaire