Regarding Matrix row subtraction! Please Help, Urgent

1 次查看(过去 30 天)
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 个评论
Rik
Rik 2018-3-18
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.

请先登录,再进行评论。

采纳的回答

John D'Errico
John D'Errico 2018-3-17
编辑:John D'Errico 2018-3-17
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by