Borrar filtros
Borrar filtros

Regarding Matrix row subtraction! Please Help, Urgent

1 visualización (últimos 30 días)
Pavel Chatterjee
Pavel Chatterjee el 17 de Mzo. de 2018
Comentada: Rik el 18 de Mzo. de 2018
HI
Consider this example
A=[6 5 6;2 4 1] A(2,2)-A(1,2) gives me a zero value. However I needed the real value in positive. I do understand that abs() would help in making it positive however I get a zero value to start with. CAN SOMEONE PLEASE HELP
  1 comentario
Rik
Rik el 18 de Mzo. de 2018
You should avoid the word urgent. The overwhelming majority of answers and other support provided on this forum is from volunteers. You can improve your chances on a fast answer by following the advice here. If someone reads your question and finds it interesting enough, you will get an answer or at least some pointers to help you along. Using words like urgent or all caps please help don't improve the odds. Actually, some people actively avoid questions with these kind of words.

Iniciar sesión para comentar.

Respuesta aceptada

John D'Errico
John D'Errico el 17 de Mzo. de 2018
Editada: John D'Errico el 17 de Mzo. de 2018
Works for me.
A=[6 5 6;2 4 1];
A(2,2)-A(1,2)
ans =
-1
I would suggest that A is probably of class uint8. (Or a similar integer class.) Verify that by whos.
whos A
Name Size Bytes Class Attributes
A 2x3 48 double
You can see that A is a double. See what happens if we change the class of A. It still looks very much the same, but...
A = uint8(A)
A =
2×3 uint8 matrix
6 5 6
2 4 1
A(2,2)-A(1,2)
ans =
uint8
0
Now we get zero.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by