Borrar filtros
Borrar filtros

array multiplication with a negative value

3 visualizaciones (últimos 30 días)
Bathrinath
Bathrinath el 11 de Jun. de 2014
Comentada: Bathrinath el 11 de Jun. de 2014
A=[0,-2.2,-3.3,-25;1.2,0,-1.1,12;2,-8,8,0] my answer is to be A=[0,-2.2,-3.3,-25;-1.2,0,-1.1,-12;-2,-8,-8,0]. I need to convert the values in A which is greater than zero as -A. I have used if A(A > 0) A=-A; end This is not working. Suggest some points

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 11 de Jun. de 2014
Editada: Andrei Bobrov el 11 de Jun. de 2014
t = A > 0;
A(t) = -A(t);
or
A = -abs(A);

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays 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