Regarding Matrix row subtraction! Please Help, Urgent
1 view (last 30 days)
Show older comments
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 Comment
Rik
on 18 Mar 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.
Accepted Answer
John D'Errico
on 17 Mar 2018
Edited: John D'Errico
on 17 Mar 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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!