Regarding Matrix row subtraction! Please Help, Urgent
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Pavel Chatterjee
il 17 Mar 2018
Commentato: Rik
il 18 Mar 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 Commento
Rik
il 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.
Risposta accettata
John D'Errico
il 17 Mar 2018
Modificato: John D'Errico
il 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!