# How to restore the negatives signs of numbers in a matrix?

1 visualización (últimos 30 días)
Mohsin Shah el 23 de Mayo de 2017
Editada: KSSV el 23 de Mayo de 2017
I have a matrix of positive and negative integers. How to remove the signs of negative integers and make them positive integers? and how can I restore the negative signs of integers? For example, i have a 3 by 3 matrix a= [-2020 -740 2888;-2022 -948 2678; -2019 1192 -2510]. I want to make a matrix with the same integer values but all positive like a= [2020 740 2888;2022 948 2678;2019 1192 2510]. I have an encryption algorithm which can only process positive integers so I need to remove the negative signs from the matrix integers and apply the encryption algorithm. Say the output of the encryption is a= [45 65 31;22 94 26;20 11 25] and then restore the signs of the integers after encryption as a= [-45 -65 31;-22 -94 26;-20 11 -25]. How to do this?
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

KSSV el 23 de Mayo de 2017
Editada: KSSV el 23 de Mayo de 2017
a= [-2020 -740 2888;-2022 -948 2678; -2019 1192 -2510] ;
b = [-45 -65 31;-22 -94 26;-20 11 -25]
iwant = sign(a).*abs(b)
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Encryption / Cryptography en Help Center y File Exchange.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by